<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>31.前台系统-预约下单 | Teng&#39;s blog</title>
    <meta name="generator" content="VuePress 1.9.7">
    <link rel="icon" href="/logo/favicon.ico">
    <meta name="description" content="">
    <meta name="keywords" content="大数据,java,h5,前端,人工智能,深度学习,go">
    <meta name="theme-color" content="#3eaf7c">
    
    <link rel="preload" href="/assets/css/0.styles.c17b3ac5.css" as="style"><link rel="preload" href="/assets/js/app.ab6a7ec7.js" as="script"><link rel="preload" href="/assets/js/2.bc9beebf.js" as="script"><link rel="preload" href="/assets/js/104.75b80350.js" as="script"><link rel="prefetch" href="/assets/js/10.829fbe09.js"><link rel="prefetch" href="/assets/js/100.21819a92.js"><link rel="prefetch" href="/assets/js/101.cba9a2fb.js"><link rel="prefetch" href="/assets/js/102.866a5b15.js"><link rel="prefetch" href="/assets/js/103.fdb7598a.js"><link rel="prefetch" href="/assets/js/105.3030b5b8.js"><link rel="prefetch" href="/assets/js/106.11a5a8f2.js"><link rel="prefetch" href="/assets/js/107.232bdd92.js"><link rel="prefetch" href="/assets/js/108.a619d3d9.js"><link rel="prefetch" href="/assets/js/109.d31480d9.js"><link rel="prefetch" href="/assets/js/11.18a3d2d0.js"><link rel="prefetch" href="/assets/js/110.7b7051ad.js"><link rel="prefetch" href="/assets/js/111.6976153b.js"><link rel="prefetch" href="/assets/js/112.935a63bd.js"><link rel="prefetch" href="/assets/js/113.77296509.js"><link rel="prefetch" href="/assets/js/114.3ab3be4a.js"><link rel="prefetch" href="/assets/js/115.9b0dac10.js"><link rel="prefetch" href="/assets/js/116.55bc2cd6.js"><link rel="prefetch" href="/assets/js/117.75bd6d05.js"><link rel="prefetch" href="/assets/js/118.0dae142d.js"><link rel="prefetch" href="/assets/js/119.b1a2888c.js"><link rel="prefetch" href="/assets/js/12.81e292a4.js"><link rel="prefetch" href="/assets/js/120.6a3fd99f.js"><link rel="prefetch" href="/assets/js/121.ea1e1714.js"><link rel="prefetch" href="/assets/js/122.125ebe03.js"><link rel="prefetch" href="/assets/js/123.ec5bcef7.js"><link rel="prefetch" href="/assets/js/124.f346a2dc.js"><link rel="prefetch" href="/assets/js/125.11061d5a.js"><link rel="prefetch" href="/assets/js/126.7f8bc26b.js"><link rel="prefetch" href="/assets/js/127.26df99b6.js"><link rel="prefetch" href="/assets/js/128.0d4aae4f.js"><link rel="prefetch" href="/assets/js/129.ec01b50e.js"><link rel="prefetch" href="/assets/js/13.89c37359.js"><link rel="prefetch" href="/assets/js/130.9e570618.js"><link rel="prefetch" href="/assets/js/131.ffaed293.js"><link rel="prefetch" href="/assets/js/132.6ef77a2c.js"><link rel="prefetch" href="/assets/js/133.893078b6.js"><link rel="prefetch" href="/assets/js/134.a5229ebf.js"><link rel="prefetch" href="/assets/js/135.e1015261.js"><link rel="prefetch" href="/assets/js/136.655ac222.js"><link rel="prefetch" href="/assets/js/137.4c18a7dc.js"><link rel="prefetch" href="/assets/js/138.17cf92aa.js"><link rel="prefetch" href="/assets/js/139.7e23a82f.js"><link rel="prefetch" href="/assets/js/14.5a11397f.js"><link rel="prefetch" href="/assets/js/140.570f33f7.js"><link rel="prefetch" href="/assets/js/141.eb538cc8.js"><link rel="prefetch" href="/assets/js/142.2f38d42f.js"><link rel="prefetch" href="/assets/js/143.a32de735.js"><link rel="prefetch" href="/assets/js/144.76a63ee6.js"><link rel="prefetch" href="/assets/js/145.42483d13.js"><link rel="prefetch" href="/assets/js/146.068119e8.js"><link rel="prefetch" href="/assets/js/147.64de6f65.js"><link rel="prefetch" href="/assets/js/148.5709a561.js"><link rel="prefetch" href="/assets/js/149.9373f1d3.js"><link rel="prefetch" href="/assets/js/15.f98080cd.js"><link rel="prefetch" href="/assets/js/150.85328596.js"><link rel="prefetch" href="/assets/js/151.8179d926.js"><link rel="prefetch" href="/assets/js/152.357ef7ac.js"><link rel="prefetch" href="/assets/js/153.a7f37700.js"><link rel="prefetch" href="/assets/js/154.259e0731.js"><link rel="prefetch" href="/assets/js/155.609478f3.js"><link rel="prefetch" href="/assets/js/156.c02413b4.js"><link rel="prefetch" href="/assets/js/157.4225246d.js"><link rel="prefetch" href="/assets/js/158.90aa3193.js"><link rel="prefetch" href="/assets/js/159.48a36d7f.js"><link rel="prefetch" href="/assets/js/16.c2c39a12.js"><link rel="prefetch" href="/assets/js/160.1483c525.js"><link rel="prefetch" href="/assets/js/161.935da955.js"><link rel="prefetch" href="/assets/js/162.623fec51.js"><link rel="prefetch" href="/assets/js/163.9b588340.js"><link rel="prefetch" href="/assets/js/164.30ec5aba.js"><link rel="prefetch" href="/assets/js/165.189a8317.js"><link rel="prefetch" href="/assets/js/166.5af6c2ec.js"><link rel="prefetch" href="/assets/js/167.9dff1ac7.js"><link rel="prefetch" href="/assets/js/168.622f7001.js"><link rel="prefetch" href="/assets/js/169.2e7169b6.js"><link rel="prefetch" href="/assets/js/17.b69c805b.js"><link rel="prefetch" href="/assets/js/170.722cbe91.js"><link rel="prefetch" href="/assets/js/171.bc79c387.js"><link rel="prefetch" href="/assets/js/172.ee6817b8.js"><link rel="prefetch" href="/assets/js/173.b35d740e.js"><link rel="prefetch" href="/assets/js/174.5c6e7df5.js"><link rel="prefetch" href="/assets/js/175.d4a5903b.js"><link rel="prefetch" href="/assets/js/176.7be8b3ab.js"><link rel="prefetch" href="/assets/js/177.21a314f9.js"><link rel="prefetch" href="/assets/js/178.7c287ca3.js"><link rel="prefetch" href="/assets/js/179.b4682242.js"><link rel="prefetch" href="/assets/js/18.8b504010.js"><link rel="prefetch" href="/assets/js/180.0098b166.js"><link rel="prefetch" href="/assets/js/181.1ade00c6.js"><link rel="prefetch" href="/assets/js/182.2cdebd59.js"><link rel="prefetch" href="/assets/js/183.019718a7.js"><link rel="prefetch" href="/assets/js/184.d4ab9703.js"><link rel="prefetch" href="/assets/js/185.50d60e28.js"><link rel="prefetch" href="/assets/js/186.3a98e144.js"><link rel="prefetch" href="/assets/js/187.9ed4524b.js"><link rel="prefetch" href="/assets/js/188.c3a8a353.js"><link rel="prefetch" href="/assets/js/189.b949cdaa.js"><link rel="prefetch" href="/assets/js/19.6860ea74.js"><link rel="prefetch" href="/assets/js/190.7a54fb5e.js"><link rel="prefetch" href="/assets/js/191.804d06a5.js"><link rel="prefetch" href="/assets/js/192.c729ba9b.js"><link rel="prefetch" href="/assets/js/193.e8d492ad.js"><link rel="prefetch" href="/assets/js/194.49b4668e.js"><link rel="prefetch" href="/assets/js/195.e4508c24.js"><link rel="prefetch" href="/assets/js/196.538420c6.js"><link rel="prefetch" href="/assets/js/197.56fda656.js"><link rel="prefetch" href="/assets/js/198.75e420ad.js"><link rel="prefetch" href="/assets/js/199.67784aef.js"><link rel="prefetch" href="/assets/js/20.82f2e898.js"><link rel="prefetch" href="/assets/js/200.b32cd750.js"><link rel="prefetch" href="/assets/js/201.594db75b.js"><link rel="prefetch" href="/assets/js/202.70b380ec.js"><link rel="prefetch" href="/assets/js/203.0de30338.js"><link rel="prefetch" href="/assets/js/204.360c28c7.js"><link rel="prefetch" href="/assets/js/205.5b4b553b.js"><link rel="prefetch" href="/assets/js/206.6bd13fc8.js"><link rel="prefetch" href="/assets/js/207.875be01b.js"><link rel="prefetch" href="/assets/js/208.00694e2b.js"><link rel="prefetch" href="/assets/js/209.1fa15603.js"><link rel="prefetch" href="/assets/js/21.3f050c1d.js"><link rel="prefetch" href="/assets/js/210.f11e4fe3.js"><link rel="prefetch" href="/assets/js/211.a9beca8a.js"><link rel="prefetch" href="/assets/js/212.2fb3a3b1.js"><link rel="prefetch" href="/assets/js/213.c2fb7dcf.js"><link rel="prefetch" href="/assets/js/214.7613f2f7.js"><link rel="prefetch" href="/assets/js/215.ac00cd4b.js"><link rel="prefetch" href="/assets/js/216.926eb535.js"><link rel="prefetch" href="/assets/js/217.e03af99a.js"><link rel="prefetch" href="/assets/js/218.0212a1a9.js"><link rel="prefetch" href="/assets/js/219.318a1817.js"><link rel="prefetch" href="/assets/js/22.f2a18e55.js"><link rel="prefetch" href="/assets/js/220.34f368ec.js"><link rel="prefetch" href="/assets/js/221.1d325330.js"><link rel="prefetch" href="/assets/js/222.f8ac9e1e.js"><link rel="prefetch" href="/assets/js/223.1d081b10.js"><link rel="prefetch" href="/assets/js/224.d4a3c833.js"><link rel="prefetch" href="/assets/js/225.86046773.js"><link rel="prefetch" href="/assets/js/226.ee01e5ed.js"><link rel="prefetch" href="/assets/js/227.cc700349.js"><link rel="prefetch" href="/assets/js/228.121d2708.js"><link rel="prefetch" href="/assets/js/229.411a1a59.js"><link rel="prefetch" href="/assets/js/23.8416a606.js"><link rel="prefetch" href="/assets/js/230.ce1cd57d.js"><link rel="prefetch" href="/assets/js/231.9e415c00.js"><link rel="prefetch" href="/assets/js/232.af1434b0.js"><link rel="prefetch" href="/assets/js/233.aedf0a69.js"><link rel="prefetch" href="/assets/js/234.7343179f.js"><link rel="prefetch" href="/assets/js/235.3ea94188.js"><link rel="prefetch" href="/assets/js/236.e632719a.js"><link rel="prefetch" href="/assets/js/237.34a70a59.js"><link rel="prefetch" href="/assets/js/238.9582b4be.js"><link rel="prefetch" href="/assets/js/239.2a1f2f8d.js"><link rel="prefetch" href="/assets/js/24.73629fb4.js"><link rel="prefetch" href="/assets/js/240.e0563eb9.js"><link rel="prefetch" href="/assets/js/241.7a2b4d6e.js"><link rel="prefetch" href="/assets/js/242.f9f59053.js"><link rel="prefetch" href="/assets/js/243.95904034.js"><link rel="prefetch" href="/assets/js/244.0c91ecaa.js"><link rel="prefetch" href="/assets/js/245.58988353.js"><link rel="prefetch" href="/assets/js/246.73360878.js"><link rel="prefetch" href="/assets/js/247.3f36cb13.js"><link rel="prefetch" href="/assets/js/248.9bca99ac.js"><link rel="prefetch" href="/assets/js/249.e78a3dbb.js"><link rel="prefetch" href="/assets/js/25.f62ba06b.js"><link rel="prefetch" href="/assets/js/250.5999a7b3.js"><link rel="prefetch" href="/assets/js/251.5204362e.js"><link rel="prefetch" href="/assets/js/252.a731f0e2.js"><link rel="prefetch" href="/assets/js/253.ef15afff.js"><link rel="prefetch" href="/assets/js/254.8e0d8aa8.js"><link rel="prefetch" href="/assets/js/255.53408731.js"><link rel="prefetch" href="/assets/js/256.3d08ae8f.js"><link rel="prefetch" href="/assets/js/257.1de6306c.js"><link rel="prefetch" href="/assets/js/258.b3ec2e6c.js"><link rel="prefetch" href="/assets/js/259.40e6c088.js"><link rel="prefetch" href="/assets/js/26.ed3d7d52.js"><link rel="prefetch" href="/assets/js/260.05ea317d.js"><link rel="prefetch" href="/assets/js/261.048af235.js"><link rel="prefetch" href="/assets/js/262.905ce2e2.js"><link rel="prefetch" href="/assets/js/263.8ace396b.js"><link rel="prefetch" href="/assets/js/264.10841fe2.js"><link rel="prefetch" href="/assets/js/265.f94f5548.js"><link rel="prefetch" href="/assets/js/266.bf7b6e06.js"><link rel="prefetch" href="/assets/js/267.4c03cbf4.js"><link rel="prefetch" href="/assets/js/268.1886e607.js"><link rel="prefetch" href="/assets/js/269.9dfca98b.js"><link rel="prefetch" href="/assets/js/27.18a2fe1c.js"><link rel="prefetch" href="/assets/js/270.a0ebdd62.js"><link rel="prefetch" href="/assets/js/271.cb9ce68b.js"><link rel="prefetch" href="/assets/js/272.99ea7c05.js"><link rel="prefetch" href="/assets/js/273.7f5c9d16.js"><link rel="prefetch" href="/assets/js/274.1ca50474.js"><link rel="prefetch" href="/assets/js/275.e0a79a93.js"><link rel="prefetch" href="/assets/js/276.5e9f441d.js"><link rel="prefetch" href="/assets/js/277.31f82a4b.js"><link rel="prefetch" href="/assets/js/278.2df5557a.js"><link rel="prefetch" href="/assets/js/279.6caef400.js"><link rel="prefetch" href="/assets/js/28.30687ae2.js"><link rel="prefetch" href="/assets/js/280.07da039a.js"><link rel="prefetch" href="/assets/js/281.81b66752.js"><link rel="prefetch" href="/assets/js/282.a362880b.js"><link rel="prefetch" href="/assets/js/283.37de8db2.js"><link rel="prefetch" href="/assets/js/284.31a9bcd5.js"><link rel="prefetch" href="/assets/js/285.e1ed9d70.js"><link rel="prefetch" href="/assets/js/286.5cd73851.js"><link rel="prefetch" href="/assets/js/287.b598b99a.js"><link rel="prefetch" href="/assets/js/288.a2580005.js"><link rel="prefetch" href="/assets/js/289.83413eb3.js"><link rel="prefetch" href="/assets/js/29.8f48fd0e.js"><link rel="prefetch" href="/assets/js/290.405974a0.js"><link rel="prefetch" href="/assets/js/291.f762f6f9.js"><link rel="prefetch" href="/assets/js/292.f5851afc.js"><link rel="prefetch" href="/assets/js/293.8e7d9ffa.js"><link rel="prefetch" href="/assets/js/294.3694f780.js"><link rel="prefetch" href="/assets/js/295.84d9cd4c.js"><link rel="prefetch" href="/assets/js/296.0a6bbe5d.js"><link rel="prefetch" href="/assets/js/297.195f8ede.js"><link rel="prefetch" href="/assets/js/3.7494bd83.js"><link rel="prefetch" href="/assets/js/30.5f000d59.js"><link rel="prefetch" href="/assets/js/31.2f3aea00.js"><link rel="prefetch" href="/assets/js/32.78912726.js"><link rel="prefetch" href="/assets/js/33.4f600444.js"><link rel="prefetch" href="/assets/js/34.1ec8259c.js"><link rel="prefetch" href="/assets/js/35.bc414639.js"><link rel="prefetch" href="/assets/js/36.b0c05f62.js"><link rel="prefetch" href="/assets/js/37.7e626d70.js"><link rel="prefetch" href="/assets/js/38.bb3a6a22.js"><link rel="prefetch" href="/assets/js/39.3d17059f.js"><link rel="prefetch" href="/assets/js/4.ff6020d1.js"><link rel="prefetch" href="/assets/js/40.2023aaeb.js"><link rel="prefetch" href="/assets/js/41.64452f22.js"><link rel="prefetch" href="/assets/js/42.32522c9c.js"><link rel="prefetch" href="/assets/js/43.ae24bdff.js"><link rel="prefetch" href="/assets/js/44.3acc6c82.js"><link rel="prefetch" href="/assets/js/45.2cec263d.js"><link rel="prefetch" href="/assets/js/46.ceacfcd8.js"><link rel="prefetch" href="/assets/js/47.59030139.js"><link rel="prefetch" href="/assets/js/48.fa5e3c59.js"><link rel="prefetch" href="/assets/js/49.2054398b.js"><link rel="prefetch" href="/assets/js/5.f2ade644.js"><link rel="prefetch" href="/assets/js/50.47a76469.js"><link rel="prefetch" href="/assets/js/51.c36ce30b.js"><link rel="prefetch" href="/assets/js/52.72ce6650.js"><link rel="prefetch" href="/assets/js/53.9dbe65dd.js"><link rel="prefetch" href="/assets/js/54.b571c195.js"><link rel="prefetch" href="/assets/js/55.3502ffd5.js"><link rel="prefetch" href="/assets/js/56.790119c4.js"><link rel="prefetch" href="/assets/js/57.aae4081b.js"><link rel="prefetch" href="/assets/js/58.e54d1920.js"><link rel="prefetch" href="/assets/js/59.6eaa8c48.js"><link rel="prefetch" href="/assets/js/6.04d544f0.js"><link rel="prefetch" href="/assets/js/60.7b2d3e47.js"><link rel="prefetch" href="/assets/js/61.093542b8.js"><link rel="prefetch" href="/assets/js/62.d0af83fd.js"><link rel="prefetch" href="/assets/js/63.b57f13fb.js"><link rel="prefetch" href="/assets/js/64.acbb2295.js"><link rel="prefetch" href="/assets/js/65.87d05864.js"><link rel="prefetch" href="/assets/js/66.773a0404.js"><link rel="prefetch" href="/assets/js/67.c66984d0.js"><link rel="prefetch" href="/assets/js/68.77bfcb54.js"><link rel="prefetch" href="/assets/js/69.7e3d1cc4.js"><link rel="prefetch" href="/assets/js/7.bc46b052.js"><link rel="prefetch" href="/assets/js/70.dbd5eb9b.js"><link rel="prefetch" href="/assets/js/71.109923c3.js"><link rel="prefetch" href="/assets/js/72.c92d7f25.js"><link rel="prefetch" href="/assets/js/73.a8ef2055.js"><link rel="prefetch" href="/assets/js/74.79119a72.js"><link rel="prefetch" href="/assets/js/75.009bcb5e.js"><link rel="prefetch" href="/assets/js/76.cba94ffd.js"><link rel="prefetch" href="/assets/js/77.caa07e47.js"><link rel="prefetch" href="/assets/js/78.fef64e9e.js"><link rel="prefetch" href="/assets/js/79.72d6eb81.js"><link rel="prefetch" href="/assets/js/8.8cf6541b.js"><link rel="prefetch" href="/assets/js/80.9370a1bd.js"><link rel="prefetch" href="/assets/js/81.f53b6c0a.js"><link rel="prefetch" href="/assets/js/82.01861305.js"><link rel="prefetch" href="/assets/js/83.4d69c6c5.js"><link rel="prefetch" href="/assets/js/84.ea80ae96.js"><link rel="prefetch" href="/assets/js/85.34c10294.js"><link rel="prefetch" href="/assets/js/86.4c7d6d58.js"><link rel="prefetch" href="/assets/js/87.ade6c1ee.js"><link rel="prefetch" href="/assets/js/88.306bb690.js"><link rel="prefetch" href="/assets/js/89.ed02954c.js"><link rel="prefetch" href="/assets/js/9.b3d99320.js"><link rel="prefetch" href="/assets/js/90.8db20502.js"><link rel="prefetch" href="/assets/js/91.3d01b6a4.js"><link rel="prefetch" href="/assets/js/92.b3dcea87.js"><link rel="prefetch" href="/assets/js/93.28790aa5.js"><link rel="prefetch" href="/assets/js/94.45722d7d.js"><link rel="prefetch" href="/assets/js/95.c04b6585.js"><link rel="prefetch" href="/assets/js/96.7c4d9328.js"><link rel="prefetch" href="/assets/js/97.85bb6089.js"><link rel="prefetch" href="/assets/js/98.e22a9c08.js"><link rel="prefetch" href="/assets/js/99.fd9f1f1d.js">
    <link rel="stylesheet" href="/assets/css/0.styles.c17b3ac5.css">
  </head>
  <body class="theme-mode-light">
    <div id="app" data-server-rendered="true"><div class="theme-container sidebar-open have-rightmenu"><header class="navbar blur"><div title="目录" class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/" class="home-link router-link-active"><img src="/logo/TB-mini.png" alt="Teng's blog" class="logo"> <span class="site-name can-hide">Teng's blog</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/" class="nav-link">首页</a></div><div class="nav-item"><a href="/note/java/" class="nav-link">Java</a></div><div class="nav-item"><a href="/note/font-end/" class="nav-link">H5前端</a></div> <a href="https://github.com/shetengteng" target="_blank" rel="noopener noreferrer" class="repo-link">
    GitHub
    <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav></div></header> <div class="sidebar-mask"></div> <div class="sidebar-hover-trigger"></div> <aside class="sidebar" style="display:none;"><!----> <nav class="nav-links"><div class="nav-item"><a href="/" class="nav-link">首页</a></div><div class="nav-item"><a href="/note/java/" class="nav-link">Java</a></div><div class="nav-item"><a href="/note/font-end/" class="nav-link">H5前端</a></div> <a href="https://github.com/shetengteng" target="_blank" rel="noopener noreferrer" class="repo-link">
    GitHub
    <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav>  <ul class="sidebar-links"><li><a href="/pages/267810/" class="sidebar-link">01.项目介绍</a></li><li><a href="/pages/8daeeb/" class="sidebar-link">02.后台系统-搭建项目</a></li><li><a href="/pages/cff01b/" class="sidebar-link">03.后台系统-医院设置模块</a></li><li><a href="/pages/a0f099/" class="sidebar-link">04.后台系统-统一异常处理</a></li><li><a href="/pages/daa6e2/" class="sidebar-link">05.后台系统-统一日志处理</a></li><li><a href="/pages/9acbf4/" class="sidebar-link">06.后台系统-搭建管理后台前端</a></li><li><a href="/pages/bd4569/" class="sidebar-link">07.后台系统-医院设置前端</a></li><li><a href="/pages/ab37bc/" class="sidebar-link">08.后台系统-数据字典</a></li><li><a href="/pages/1590ab/" class="sidebar-link">09.SpringCache+Redis缓存数据</a></li><li><a href="/pages/f4f60f/" class="sidebar-link">10.集成与配置Nginx</a></li><li><a href="/pages/cfa99b/" class="sidebar-link">11.启动医院接口模拟系统</a></li><li><a href="/pages/5a3f28/" class="sidebar-link">12.后台系统-上传医院信息</a></li><li><a href="/pages/85c8c5/" class="sidebar-link">13.后台系统-上传科室信息</a></li><li><a href="/pages/2bfc0d/" class="sidebar-link">14.后台系统-上传排班信息</a></li><li><a href="/pages/5dab7a/" class="sidebar-link">15.搭建服务注册中心Nacos</a></li><li><a href="/pages/c3a646/" class="sidebar-link">16.后台系统-医院管理</a></li><li><a href="/pages/65fa50/" class="sidebar-link">17.后台系统-排班管理</a></li><li><a href="/pages/e75b32/" class="sidebar-link">18.搭建服务网关Gateway</a></li><li><a href="/pages/3e1a3d/" class="sidebar-link">19.前台系统-搭建前端环境</a></li><li><a href="/pages/a5886b/" class="sidebar-link">20.前台系统-首页</a></li><li><a href="/pages/89220e/" class="sidebar-link">21.前台系统-医院详情页</a></li><li><a href="/pages/707098/" class="sidebar-link">22.前台系统-用户登录</a></li><li><a href="/pages/adcd3d/" class="sidebar-link">23.后台系统-短信服务</a></li><li><a href="/pages/26ab86/" class="sidebar-link">24.用户认证与网关整合</a></li><li><a href="/pages/035c93/" class="sidebar-link">25.前台系统-微信登录</a></li><li><a href="/pages/0196f4/" class="sidebar-link">26.前台系统-实名认证</a></li><li><a href="/pages/919f67/" class="sidebar-link">27.前台系统-就诊人管理</a></li><li><a href="/pages/2d8bd8/" class="sidebar-link">28.后台系统-平台用户管理</a></li><li><a href="/pages/2edc4a/" class="sidebar-link">29.前台系统-预约挂号详情</a></li><li><a href="/pages/42181a/" class="sidebar-link">30.前台系统-预约确认</a></li><li><a href="/pages/91c38e/" aria-current="page" class="active sidebar-link">31.前台系统-预约下单</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/pages/91c38e/#需求分析" class="sidebar-link">需求分析</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/pages/91c38e/#数据库表结构" class="sidebar-link">数据库表结构</a></li><li class="sidebar-sub-header"><a href="/pages/91c38e/#预约下单接口定义" class="sidebar-link">预约下单接口定义</a></li><li class="sidebar-sub-header"><a href="/pages/91c38e/#设计流程" class="sidebar-link">设计流程</a></li></ul></li><li class="sidebar-sub-header"><a href="/pages/91c38e/#搭建service-order模块" class="sidebar-link">搭建service-order模块</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/pages/91c38e/#修改pom" class="sidebar-link">修改pom</a></li><li class="sidebar-sub-header"><a href="/pages/91c38e/#添加配置文件" class="sidebar-link">添加配置文件</a></li><li class="sidebar-sub-header"><a href="/pages/91c38e/#编写启动类" class="sidebar-link">编写启动类</a></li><li class="sidebar-sub-header"><a href="/pages/91c38e/#配置网关-service-gateway" class="sidebar-link">配置网关 service-gateway</a></li></ul></li><li class="sidebar-sub-header"><a href="/pages/91c38e/#添加订单基础类" class="sidebar-link">添加订单基础类</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/pages/91c38e/#添加model" class="sidebar-link">添加model</a></li><li class="sidebar-sub-header"><a href="/pages/91c38e/#添加mapper" class="sidebar-link">添加mapper</a></li><li class="sidebar-sub-header"><a href="/pages/91c38e/#添加service以及实现类" class="sidebar-link">添加service以及实现类</a></li><li class="sidebar-sub-header"><a href="/pages/91c38e/#添加controller" class="sidebar-link">添加controller</a></li></ul></li><li class="sidebar-sub-header"><a href="/pages/91c38e/#封装feign获取就诊人信息" class="sidebar-link">封装feign获取就诊人信息</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/pages/91c38e/#添加获取就诊人信息接口-service-user" class="sidebar-link">添加获取就诊人信息接口 service-user</a></li><li class="sidebar-sub-header"><a href="/pages/91c38e/#搭建service-user-client模块" class="sidebar-link">搭建service-user-client模块</a></li></ul></li><li class="sidebar-sub-header"><a href="/pages/91c38e/#封装feign获取排班下单信息" class="sidebar-link">封装feign获取排班下单信息</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/pages/91c38e/#添加排班下单信息-model" class="sidebar-link">添加排班下单信息 model</a></li><li class="sidebar-sub-header"><a href="/pages/91c38e/#添加获取排班下单信息接口-service-hosp" class="sidebar-link">添加获取排班下单信息接口 service-hosp</a></li><li class="sidebar-sub-header"><a href="/pages/91c38e/#添加签名信息-model" class="sidebar-link">添加签名信息 model</a></li><li class="sidebar-sub-header"><a href="/pages/91c38e/#获取下单签名引用信息接口-service-hosp" class="sidebar-link">获取下单签名引用信息接口 service-hosp</a></li><li class="sidebar-sub-header"><a href="/pages/91c38e/#搭建service-hosp-client模块" class="sidebar-link">搭建service-hosp-client模块</a></li></ul></li><li class="sidebar-sub-header"><a href="/pages/91c38e/#实现下单接口-service-order" class="sidebar-link">实现下单接口 service-order</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/pages/91c38e/#添加feign模块依赖" class="sidebar-link">添加feign模块依赖</a></li><li class="sidebar-sub-header"><a href="/pages/91c38e/#封装下单工具类" class="sidebar-link">封装下单工具类</a></li><li class="sidebar-sub-header"><a href="/pages/91c38e/#实现保存订单方法" class="sidebar-link">实现保存订单方法</a></li></ul></li><li class="sidebar-sub-header"><a href="/pages/91c38e/#预约成功后处理" class="sidebar-link">预约成功后处理</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/pages/91c38e/#创建rabbitmq-util模块" class="sidebar-link">创建rabbitmq-util模块</a></li><li class="sidebar-sub-header"><a href="/pages/91c38e/#封装短信接口-service-msm" class="sidebar-link">封装短信接口 service-msm</a></li><li class="sidebar-sub-header"><a href="/pages/91c38e/#封装更新排班数量-service-hosp" class="sidebar-link">封装更新排班数量 service-hosp</a></li><li class="sidebar-sub-header"><a href="/pages/91c38e/#调整下单接口-service-order" class="sidebar-link">调整下单接口 service-order</a></li></ul></li><li class="sidebar-sub-header"><a href="/pages/91c38e/#前端实现-yygh-site" class="sidebar-link">前端实现 yygh-site</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/pages/91c38e/#封装api请求" class="sidebar-link">封装api请求</a></li><li class="sidebar-sub-header"><a href="/pages/91c38e/#修改页面" class="sidebar-link">修改页面</a></li></ul></li><li class="sidebar-sub-header"><a href="/pages/91c38e/#测试" class="sidebar-link">测试</a></li></ul></li><li><a href="/pages/9b5903/" class="sidebar-link">32.前台系统-订单管理</a></li><li><a href="/pages/046eb0/" class="sidebar-link">33.后台系统-订单管理</a></li><li><a href="/pages/a11a73/" class="sidebar-link">34.前台系统-微信支付</a></li><li><a href="/pages/31eaca/" class="sidebar-link">35.前台系统-取消预约</a></li><li><a href="/pages/3b3641/" class="sidebar-link">36.前台系统-就医提醒</a></li><li><a href="/pages/3d23db/" class="sidebar-link">37.后台系统-预约统计</a></li><li><a href="/pages/9d4d38/" class="sidebar-link">38.小结</a></li><li><a href="/pages/1d8134/" class="sidebar-link">附录：医院接口模拟系统说明</a></li><li><a href="/pages/678e2d/" class="sidebar-link">附录：在线预约挂号API接口文档</a></li></ul> </aside> <div><main class="page"><div class="theme-vdoing-wrapper "><div class="articleInfo-wrap" data-v-0c557b5e><div class="articleInfo" data-v-0c557b5e><ul class="breadcrumbs" data-v-0c557b5e><li data-v-0c557b5e><a href="/" title="首页" class="iconfont icon-home router-link-active" data-v-0c557b5e></a></li> <li data-v-0c557b5e><span data-v-0c557b5e>Project-尚医通</span></li></ul> <div class="info" data-v-0c557b5e><div title="作者" class="author iconfont icon-touxiang" data-v-0c557b5e><a href="https://github.com/shetengteng" target="_blank" title="作者" class="beLink" data-v-0c557b5e>Shetengteng</a></div> <div title="创建时间" class="date iconfont icon-riqi" data-v-0c557b5e><a href="javascript:;" data-v-0c557b5e>2022-01-02</a></div> <!----></div></div></div> <!----> <div class="content-wrapper"><div class="right-menu-wrapper"><div class="right-menu-margin"><div class="right-menu-content"></div></div></div> <h1><!---->31.前台系统-预约下单<!----></h1>  <div class="theme-vdoing-content content__default"><h2 id="需求分析"><a href="#需求分析" class="header-anchor">#</a> 需求分析</h2> <h3 id="数据库表结构"><a href="#数据库表结构" class="header-anchor">#</a> 数据库表结构</h3> <p>查看<code>yygh_order</code>库中的<code>order_info</code>表信息查看订单表字段</p> <ul><li>包含医院信息，科室信息，排班信息</li> <li>包含就诊人信息</li> <li>包含预约序号等信息</li></ul> <div class="language-sql line-numbers-mode"><pre class="language-sql"><code><span class="token comment">-- auto-generated definition</span>
<span class="token keyword">create</span> <span class="token keyword">table</span> order_info
<span class="token punctuation">(</span>
    id              <span class="token keyword">bigint</span> <span class="token keyword">auto_increment</span> <span class="token keyword">comment</span> <span class="token string">'编号'</span> <span class="token keyword">primary</span> <span class="token keyword">key</span><span class="token punctuation">,</span>
    user_id         <span class="token keyword">bigint</span>                              <span class="token boolean">null</span><span class="token punctuation">,</span>
    out_trade_no    <span class="token keyword">varchar</span><span class="token punctuation">(</span><span class="token number">300</span><span class="token punctuation">)</span>                        <span class="token boolean">null</span> <span class="token keyword">comment</span> <span class="token string">'订单交易号'</span><span class="token punctuation">,</span>
    hoscode         <span class="token keyword">varchar</span><span class="token punctuation">(</span><span class="token number">30</span><span class="token punctuation">)</span>                         <span class="token boolean">null</span> <span class="token keyword">comment</span> <span class="token string">'医院编号'</span><span class="token punctuation">,</span>
    hosname         <span class="token keyword">varchar</span><span class="token punctuation">(</span><span class="token number">100</span><span class="token punctuation">)</span>                        <span class="token boolean">null</span> <span class="token keyword">comment</span> <span class="token string">'医院名称'</span><span class="token punctuation">,</span>
    depcode         <span class="token keyword">varchar</span><span class="token punctuation">(</span><span class="token number">30</span><span class="token punctuation">)</span>                         <span class="token boolean">null</span> <span class="token keyword">comment</span> <span class="token string">'科室编号'</span><span class="token punctuation">,</span>
    depname         <span class="token keyword">varchar</span><span class="token punctuation">(</span><span class="token number">20</span><span class="token punctuation">)</span>                         <span class="token boolean">null</span> <span class="token keyword">comment</span> <span class="token string">'科室名称'</span><span class="token punctuation">,</span>
    title           <span class="token keyword">varchar</span><span class="token punctuation">(</span><span class="token number">20</span><span class="token punctuation">)</span>                         <span class="token boolean">null</span> <span class="token keyword">comment</span> <span class="token string">'医生职称'</span><span class="token punctuation">,</span>
    hos_schedule_id <span class="token keyword">varchar</span><span class="token punctuation">(</span><span class="token number">50</span><span class="token punctuation">)</span>                         <span class="token boolean">null</span> <span class="token keyword">comment</span> <span class="token string">'排班编号（医院自己的排班主键）'</span><span class="token punctuation">,</span>
    reserve_date    <span class="token keyword">date</span>                                <span class="token boolean">null</span> <span class="token keyword">comment</span> <span class="token string">'安排日期'</span><span class="token punctuation">,</span>
    reserve_time    <span class="token keyword">tinyint</span>   <span class="token keyword">default</span> <span class="token number">0</span>                 <span class="token boolean">null</span> <span class="token keyword">comment</span> <span class="token string">'安排时间（0：上午 1：下午）'</span><span class="token punctuation">,</span>
    patient_id      <span class="token keyword">bigint</span>                              <span class="token boolean">null</span> <span class="token keyword">comment</span> <span class="token string">'就诊人id'</span><span class="token punctuation">,</span>
    patient_name    <span class="token keyword">varchar</span><span class="token punctuation">(</span><span class="token number">20</span><span class="token punctuation">)</span>                         <span class="token boolean">null</span> <span class="token keyword">comment</span> <span class="token string">'就诊人名称'</span><span class="token punctuation">,</span>
    patient_phone   <span class="token keyword">varchar</span><span class="token punctuation">(</span><span class="token number">11</span><span class="token punctuation">)</span>                         <span class="token boolean">null</span> <span class="token keyword">comment</span> <span class="token string">'就诊人手机'</span><span class="token punctuation">,</span>
    hos_record_id   <span class="token keyword">varchar</span><span class="token punctuation">(</span><span class="token number">30</span><span class="token punctuation">)</span>                         <span class="token boolean">null</span> <span class="token keyword">comment</span> <span class="token string">'预约记录唯一标识（医院预约记录主键）'</span><span class="token punctuation">,</span>
    number          <span class="token keyword">int</span>                                 <span class="token boolean">null</span> <span class="token keyword">comment</span> <span class="token string">'预约号序'</span><span class="token punctuation">,</span>
    fetch_time      <span class="token keyword">varchar</span><span class="token punctuation">(</span><span class="token number">50</span><span class="token punctuation">)</span>                         <span class="token boolean">null</span> <span class="token keyword">comment</span> <span class="token string">'建议取号时间'</span><span class="token punctuation">,</span>
    fetch_address   <span class="token keyword">varchar</span><span class="token punctuation">(</span><span class="token number">255</span><span class="token punctuation">)</span>                        <span class="token boolean">null</span> <span class="token keyword">comment</span> <span class="token string">'取号地点'</span><span class="token punctuation">,</span>
    amount          <span class="token keyword">decimal</span>                             <span class="token boolean">null</span> <span class="token keyword">comment</span> <span class="token string">'医事服务费'</span><span class="token punctuation">,</span>
    quit_time       <span class="token keyword">datetime</span>                            <span class="token boolean">null</span> <span class="token keyword">comment</span> <span class="token string">'退号时间'</span><span class="token punctuation">,</span>
    order_status    <span class="token keyword">tinyint</span>                             <span class="token boolean">null</span> <span class="token keyword">comment</span> <span class="token string">'订单状态'</span><span class="token punctuation">,</span>
    create_time     <span class="token keyword">timestamp</span> <span class="token keyword">default</span> <span class="token keyword">CURRENT_TIMESTAMP</span> <span class="token operator">not</span> <span class="token boolean">null</span> <span class="token keyword">comment</span> <span class="token string">'创建时间'</span><span class="token punctuation">,</span>
    update_time     <span class="token keyword">timestamp</span> <span class="token keyword">default</span> <span class="token keyword">CURRENT_TIMESTAMP</span> <span class="token operator">not</span> <span class="token boolean">null</span> <span class="token keyword">on</span> <span class="token keyword">update</span> <span class="token keyword">CURRENT_TIMESTAMP</span> <span class="token keyword">comment</span> <span class="token string">'更新时间'</span><span class="token punctuation">,</span>
    is_deleted      <span class="token keyword">tinyint</span>   <span class="token keyword">default</span> <span class="token number">0</span>                 <span class="token operator">not</span> <span class="token boolean">null</span> <span class="token keyword">comment</span> <span class="token string">'逻辑删除(1:已删除，0:未删除)'</span><span class="token punctuation">,</span>
    <span class="token keyword">constraint</span> uk_out_trade_no <span class="token keyword">unique</span> <span class="token punctuation">(</span>out_trade_no<span class="token punctuation">)</span>
<span class="token punctuation">)</span>  <span class="token keyword">comment</span> <span class="token string">'订单表'</span><span class="token punctuation">;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br></div></div><h3 id="预约下单接口定义"><a href="#预约下单接口定义" class="header-anchor">#</a> 预约下单接口定义</h3> <p>医院的基本信息与规则信息</p> <p>参考 【附录：在线预约挂号API接口文档】 业务接口-预约下单</p> <h4 id="提交地址"><a href="#提交地址" class="header-anchor">#</a> 提交地址</h4> <p>${basePath}/order/submitOrder</p> <h4 id="请求参数"><a href="#请求参数" class="header-anchor">#</a> 请求参数</h4> <p>变量定义</p> <table><thead><tr><th>字段名</th> <th>类型</th> <th>长度</th> <th>必输</th> <th>说明</th></tr></thead> <tbody><tr><td>hoscode</td> <td>string</td> <td>30</td> <td>是</td> <td>给医院分配的唯一标识</td></tr> <tr><td>depcode</td> <td>string</td> <td>20</td> <td>是</td> <td>科室编号</td></tr> <tr><td>hosScheduleId</td> <td>string</td> <td>30</td> <td></td> <td>排班编号（医院自己的排班主键）</td></tr> <tr><td>reserveDate</td> <td>string</td> <td>10</td> <td>是</td> <td>安排日期（yyyy-MM-dd）</td></tr> <tr><td>reserveTime</td> <td>int</td> <td></td> <td>是</td> <td>安排时间（0：上午 1：下午）</td></tr> <tr><td>amount</td> <td>string</td> <td>5</td> <td></td> <td>挂号费</td></tr> <tr><td>name</td> <td>string</td> <td>20</td> <td></td> <td>就诊人姓名</td></tr> <tr><td>sex</td> <td>int</td> <td></td> <td></td> <td>就诊人性别</td></tr> <tr><td>birthdate</td> <td>string</td> <td>20</td> <td></td> <td>就诊人出生年月</td></tr> <tr><td>phone</td> <td>string</td> <td>11</td> <td></td> <td>就诊人手机</td></tr> <tr><td>isMarry</td> <td>int</td> <td></td> <td></td> <td>就诊人是否结婚</td></tr> <tr><td>provinceCode</td> <td>string</td> <td>50</td> <td></td> <td></td></tr> <tr><td>cityCode</td> <td>string</td> <td>50</td> <td>是</td> <td>市code（国家统计局对应市的code）</td></tr> <tr><td>districtCode</td> <td>string</td> <td>10</td> <td>是</td> <td>区code（国家统计局对应区的code）</td></tr> <tr><td>address</td> <td>string</td> <td>20</td> <td>是</td> <td>就诊人详情地址</td></tr> <tr><td>contactsName</td> <td>string</td> <td>11</td> <td>是</td> <td>联系人姓名</td></tr> <tr><td>contactsCertificatesType</td> <td>int</td> <td></td> <td>否</td> <td>联系人证件类型</td></tr> <tr><td>contactsCertificatesNo</td> <td>string</td> <td>30</td> <td>是</td> <td>联系人证件号</td></tr> <tr><td>contactsPhone</td> <td>string</td> <td>11</td> <td>是</td> <td>联系人手机</td></tr> <tr><td>isInsure</td> <td>int</td> <td></td> <td></td> <td>是否有医保</td></tr> <tr><td>timestamp</td> <td>long</td> <td></td> <td>是</td> <td>时间戳。从1970-01-01 00:00:00算起的毫秒数</td></tr> <tr><td>sign</td> <td>string</td> <td>32</td> <td>是</td> <td>验签参数</td></tr></tbody></table> <h4 id="同步返回"><a href="#同步返回" class="header-anchor">#</a> 同步返回</h4> <p>结果参数含义</p> <table><thead><tr><th><strong>字段名</strong></th> <th><strong>类型</strong></th> <th><strong>长度</strong></th> <th><strong>必输</strong></th> <th><strong>说明</strong></th></tr></thead> <tbody><tr><td>code</td> <td>string</td> <td></td> <td>是</td> <td>结果编码。  200：请求成功  不等于200：请求失败（message：失败原因）</td></tr> <tr><td>message</td> <td>string</td> <td>100</td> <td>是</td> <td>结果描述</td></tr> <tr><td>data</td> <td>string</td> <td>5000</td> <td>是</td> <td>业务数据</td></tr></tbody></table> <p>data业务数据字段</p> <table><thead><tr><th><strong>字段名</strong></th> <th><strong>类型</strong></th> <th><strong>长度</strong></th> <th><strong>必输</strong></th> <th><strong>说明</strong></th></tr></thead> <tbody><tr><td>hosRecordId</td> <td>string</td> <td></td> <td>是</td> <td>预约记录唯一标识（医院预约记录主键）</td></tr> <tr><td>number</td> <td>int</td> <td></td> <td>是</td> <td>预约序号</td></tr> <tr><td>reservedNumber</td> <td>int</td> <td></td> <td>是</td> <td>排班可预约数</td></tr> <tr><td>availableNumber</td> <td>int</td> <td></td> <td>是</td> <td>排班剩余预约数</td></tr> <tr><td>fetchTime</td> <td>string</td> <td>50</td> <td>是</td> <td>取号时间</td></tr> <tr><td>fetchAddress</td> <td>string</td> <td>200</td> <td>是</td> <td>取号地址</td></tr></tbody></table> <h3 id="设计流程"><a href="#设计流程" class="header-anchor">#</a> 设计流程</h3> <blockquote><p>下单参数：就诊人id与排班id</p></blockquote> <p>下单要获取就诊人信息</p> <ul><li>通过feign调用 service-user模块，查询得到</li></ul> <p>获取排班下单信息与规则信息</p> <ul><li>通过feign调用service-hosp模块，查询得到</li></ul> <p><strong>获取医院签名信息，然后通过调用医院模拟系统接口预约下单</strong></p> <p>下单成功更新排班信息与发送短信</p> <h2 id="搭建service-order模块"><a href="#搭建service-order模块" class="header-anchor">#</a> 搭建service-order模块</h2> <p>搭建过程参考service-user模块</p> <h3 id="修改pom"><a href="#修改pom" class="header-anchor">#</a> 修改pom</h3> <p>添加 <code>service-cmn-client</code> 依赖</p> <div class="language-xml line-numbers-mode"><pre class="language-xml"><code><span class="token prolog">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>project</span> <span class="token attr-name">xmlns</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://maven.apache.org/POM/4.0.0<span class="token punctuation">&quot;</span></span>
         <span class="token attr-name"><span class="token namespace">xmlns:</span>xsi</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://www.w3.org/2001/XMLSchema-instance<span class="token punctuation">&quot;</span></span>
         <span class="token attr-name"><span class="token namespace">xsi:</span>schemaLocation</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>parent</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>service<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>com.stt.yygh<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>0.0.1<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>parent</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>modelVersion</span><span class="token punctuation">&gt;</span></span>4.0.0<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>modelVersion</span><span class="token punctuation">&gt;</span></span>

    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>1.0<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>service-order<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>packaging</span><span class="token punctuation">&gt;</span></span>jar<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>packaging</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>name</span><span class="token punctuation">&gt;</span></span>service-order<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>name</span><span class="token punctuation">&gt;</span></span>
    
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>description</span><span class="token punctuation">&gt;</span></span>service-order<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>description</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>properties</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>maven.compiler.source</span><span class="token punctuation">&gt;</span></span>8<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>maven.compiler.source</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>maven.compiler.target</span><span class="token punctuation">&gt;</span></span>8<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>maven.compiler.target</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>properties</span><span class="token punctuation">&gt;</span></span>

    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependencies</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>com.stt.yygh<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>service-cmn-client<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>1.0<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependencies</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>project</span><span class="token punctuation">&gt;</span></span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br></div></div><h3 id="添加配置文件"><a href="#添加配置文件" class="header-anchor">#</a> 添加配置文件</h3> <p>创建<code>application.properties</code>文件并添加如下内容</p> <ul><li>添加mysql配置</li> <li>添加mongodb配置</li> <li>添加nacos配置</li> <li>添加rabbitmq配置</li></ul> <div class="language-properties line-numbers-mode"><pre class="language-properties"><code><span class="token comment"># 服务端口</span>
<span class="token attr-name">server.port</span><span class="token punctuation">=</span><span class="token attr-value">8206</span>
<span class="token comment"># 服务名</span>
<span class="token attr-name">spring.application.name</span><span class="token punctuation">=</span><span class="token attr-value">service-order</span>
<span class="token comment"># 环境设置：dev、test、prod</span>
<span class="token attr-name">spring.profiles.active</span><span class="token punctuation">=</span><span class="token attr-value">dev</span>

<span class="token comment"># mysql数据库连接</span>
<span class="token attr-name">spring.datasource.driver-class-name</span><span class="token punctuation">=</span><span class="token attr-value">com.mysql.jdbc.Driver</span>
<span class="token attr-name">spring.datasource.url</span><span class="token punctuation">=</span><span class="token attr-value">jdbc:mysql://localhost:3306/yygh_order?characterEncoding=utf-8&amp;useSSL=false</span>
<span class="token attr-name">spring.datasource.username</span><span class="token punctuation">=</span><span class="token attr-value">root</span>
<span class="token attr-name">spring.datasource.password</span><span class="token punctuation">=</span><span class="token attr-value">123456</span>

<span class="token comment">#返回json的全局时间格式</span>
<span class="token attr-name">spring.jackson.date-format</span><span class="token punctuation">=</span><span class="token attr-value">yyyy-MM-dd HH:mm:ss</span>
<span class="token attr-name">spring.jackson.time-zone</span><span class="token punctuation">=</span><span class="token attr-value">GMT+8</span>

<span class="token attr-name">spring.data.mongodb.uri</span><span class="token punctuation">=</span><span class="token attr-value">mongodb://localhost:27017/yygh_hosp</span>

<span class="token comment"># nacos服务地址</span>
<span class="token attr-name">spring.cloud.nacos.discovery.server-addr</span><span class="token punctuation">=</span><span class="token attr-value">localhost:8848</span>

<span class="token comment">#rabbitmq地址</span>
<span class="token attr-name">spring.rabbitmq.host</span><span class="token punctuation">=</span><span class="token attr-value">localhost</span>
<span class="token attr-name">spring.rabbitmq.port</span><span class="token punctuation">=</span><span class="token attr-value">5672</span>
<span class="token attr-name">spring.rabbitmq.username</span><span class="token punctuation">=</span><span class="token attr-value">guest</span>
<span class="token attr-name">spring.rabbitmq.password</span><span class="token punctuation">=</span><span class="token attr-value">guest</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br></div></div><h3 id="编写启动类"><a href="#编写启动类" class="header-anchor">#</a> 编写启动类</h3> <p>创建 <code>com.stt.yygh.order.ServiceOrderApplication</code> 类，并添加如下内容</p> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>order</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>boot<span class="token punctuation">.</span></span><span class="token class-name">SpringApplication</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>boot<span class="token punctuation">.</span>autoconfigure<span class="token punctuation">.</span></span><span class="token class-name">SpringBootApplication</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>cloud<span class="token punctuation">.</span>client<span class="token punctuation">.</span>discovery<span class="token punctuation">.</span></span><span class="token class-name">EnableDiscoveryClient</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>cloud<span class="token punctuation">.</span>openfeign<span class="token punctuation">.</span></span><span class="token class-name">EnableFeignClients</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>context<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span></span><span class="token class-name">ComponentScan</span><span class="token punctuation">;</span>

<span class="token annotation punctuation">@SpringBootApplication</span>
<span class="token annotation punctuation">@EnableDiscoveryClient</span>
<span class="token annotation punctuation">@ComponentScan</span><span class="token punctuation">(</span>basePackages <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token string">&quot;com.stt&quot;</span><span class="token punctuation">}</span><span class="token punctuation">)</span>
<span class="token annotation punctuation">@EnableFeignClients</span><span class="token punctuation">(</span>basePackages <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token string">&quot;com.stt&quot;</span><span class="token punctuation">}</span><span class="token punctuation">)</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">ServiceOrderApplication</span> <span class="token punctuation">{</span>
    <span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">void</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token class-name">String</span><span class="token punctuation">[</span><span class="token punctuation">]</span> args<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token class-name">SpringApplication</span><span class="token punctuation">.</span><span class="token function">run</span><span class="token punctuation">(</span><span class="token class-name">ServiceOrderApplication</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">,</span> args<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br></div></div><h3 id="配置网关-service-gateway"><a href="#配置网关-service-gateway" class="header-anchor">#</a> 配置网关 service-gateway</h3> <p>在网关服务的<code>application.properties</code>中配置order相关路径，注意重启gateway服务</p> <div class="language-properties line-numbers-mode"><pre class="language-properties"><code><span class="token comment">#设置路由id</span>
<span class="token attr-name">spring.cloud.gateway.routes[6].id</span><span class="token punctuation">=</span><span class="token attr-value">service-order</span>
<span class="token attr-name">spring.cloud.gateway.routes[6].uri</span><span class="token punctuation">=</span><span class="token attr-value">lb://service-order</span>
<span class="token attr-name">spring.cloud.gateway.routes[6].predicates</span><span class="token punctuation">=</span> <span class="token attr-value">Path=/*/order/**</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><h2 id="添加订单基础类"><a href="#添加订单基础类" class="header-anchor">#</a> 添加订单基础类</h2> <h3 id="添加model"><a href="#添加model" class="header-anchor">#</a> 添加model</h3> <p>在 <code>model</code>模块中添加 <code>com.stt.yygh.model.order.OrderInfo</code> 类，如果已经添加可以忽略</p> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>model<span class="token punctuation">.</span>order</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>model<span class="token punctuation">.</span>base<span class="token punctuation">.</span></span><span class="token class-name">BaseEntity</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>baomidou<span class="token punctuation">.</span>mybatisplus<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span></span><span class="token class-name">TableField</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>baomidou<span class="token punctuation">.</span>mybatisplus<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span></span><span class="token class-name">TableName</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>fasterxml<span class="token punctuation">.</span>jackson<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span></span><span class="token class-name">JsonFormat</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">io<span class="token punctuation">.</span>swagger<span class="token punctuation">.</span>annotations<span class="token punctuation">.</span></span><span class="token class-name">ApiModel</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">io<span class="token punctuation">.</span>swagger<span class="token punctuation">.</span>annotations<span class="token punctuation">.</span></span><span class="token class-name">ApiModelProperty</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">lombok<span class="token punctuation">.</span></span><span class="token class-name">Data</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token namespace">java<span class="token punctuation">.</span>math<span class="token punctuation">.</span></span><span class="token class-name">BigDecimal</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">Date</span><span class="token punctuation">;</span>

<span class="token annotation punctuation">@Data</span>
<span class="token annotation punctuation">@ApiModel</span><span class="token punctuation">(</span>description <span class="token operator">=</span> <span class="token string">&quot;Order&quot;</span><span class="token punctuation">)</span>
<span class="token annotation punctuation">@TableName</span><span class="token punctuation">(</span><span class="token string">&quot;order_info&quot;</span><span class="token punctuation">)</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">OrderInfo</span> <span class="token keyword">extends</span> <span class="token class-name">BaseEntity</span> <span class="token punctuation">{</span>
	
	<span class="token keyword">private</span> <span class="token keyword">static</span> <span class="token keyword">final</span> <span class="token keyword">long</span> serialVersionUID <span class="token operator">=</span> <span class="token number">1L</span><span class="token punctuation">;</span>

	<span class="token annotation punctuation">@ApiModelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;userId&quot;</span><span class="token punctuation">)</span>
	<span class="token annotation punctuation">@TableField</span><span class="token punctuation">(</span><span class="token string">&quot;user_id&quot;</span><span class="token punctuation">)</span>
	<span class="token keyword">private</span> <span class="token class-name">Long</span> userId<span class="token punctuation">;</span>

	<span class="token annotation punctuation">@ApiModelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;订单交易号&quot;</span><span class="token punctuation">)</span>
	<span class="token annotation punctuation">@TableField</span><span class="token punctuation">(</span><span class="token string">&quot;out_trade_no&quot;</span><span class="token punctuation">)</span>
	<span class="token keyword">private</span> <span class="token class-name">String</span> outTradeNo<span class="token punctuation">;</span>

	<span class="token annotation punctuation">@ApiModelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;医院编号&quot;</span><span class="token punctuation">)</span>
	<span class="token annotation punctuation">@TableField</span><span class="token punctuation">(</span><span class="token string">&quot;hoscode&quot;</span><span class="token punctuation">)</span>
	<span class="token keyword">private</span> <span class="token class-name">String</span> hoscode<span class="token punctuation">;</span>

	<span class="token annotation punctuation">@ApiModelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;医院名称&quot;</span><span class="token punctuation">)</span>
	<span class="token annotation punctuation">@TableField</span><span class="token punctuation">(</span><span class="token string">&quot;hosname&quot;</span><span class="token punctuation">)</span>
	<span class="token keyword">private</span> <span class="token class-name">String</span> hosname<span class="token punctuation">;</span>

	<span class="token annotation punctuation">@ApiModelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;科室编号&quot;</span><span class="token punctuation">)</span>
	<span class="token annotation punctuation">@TableField</span><span class="token punctuation">(</span><span class="token string">&quot;depcode&quot;</span><span class="token punctuation">)</span>
	<span class="token keyword">private</span> <span class="token class-name">String</span> depcode<span class="token punctuation">;</span>

	<span class="token annotation punctuation">@ApiModelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;科室名称&quot;</span><span class="token punctuation">)</span>
	<span class="token annotation punctuation">@TableField</span><span class="token punctuation">(</span><span class="token string">&quot;depname&quot;</span><span class="token punctuation">)</span>
	<span class="token keyword">private</span> <span class="token class-name">String</span> depname<span class="token punctuation">;</span>

	<span class="token annotation punctuation">@ApiModelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;排班id&quot;</span><span class="token punctuation">)</span>
	<span class="token annotation punctuation">@TableField</span><span class="token punctuation">(</span><span class="token string">&quot;hos_schedule_id&quot;</span><span class="token punctuation">)</span>
	<span class="token keyword">private</span> <span class="token class-name">String</span> scheduleId<span class="token punctuation">;</span>

	<span class="token annotation punctuation">@ApiModelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;医生职称&quot;</span><span class="token punctuation">)</span>
	<span class="token annotation punctuation">@TableField</span><span class="token punctuation">(</span><span class="token string">&quot;title&quot;</span><span class="token punctuation">)</span>
	<span class="token keyword">private</span> <span class="token class-name">String</span> title<span class="token punctuation">;</span>

	<span class="token annotation punctuation">@ApiModelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;安排日期&quot;</span><span class="token punctuation">)</span>
	<span class="token annotation punctuation">@JsonFormat</span><span class="token punctuation">(</span>pattern <span class="token operator">=</span> <span class="token string">&quot;yyyy-MM-dd&quot;</span><span class="token punctuation">)</span>
	<span class="token annotation punctuation">@TableField</span><span class="token punctuation">(</span><span class="token string">&quot;reserve_date&quot;</span><span class="token punctuation">)</span>
	<span class="token keyword">private</span> <span class="token class-name">Date</span> reserveDate<span class="token punctuation">;</span>

	<span class="token annotation punctuation">@ApiModelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;安排时间（0：上午 1：下午）&quot;</span><span class="token punctuation">)</span>
	<span class="token annotation punctuation">@TableField</span><span class="token punctuation">(</span><span class="token string">&quot;reserve_time&quot;</span><span class="token punctuation">)</span>
	<span class="token keyword">private</span> <span class="token class-name">Integer</span> reserveTime<span class="token punctuation">;</span>

	<span class="token annotation punctuation">@ApiModelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;就诊人id&quot;</span><span class="token punctuation">)</span>
	<span class="token annotation punctuation">@TableField</span><span class="token punctuation">(</span><span class="token string">&quot;patient_id&quot;</span><span class="token punctuation">)</span>
	<span class="token keyword">private</span> <span class="token class-name">Long</span> patientId<span class="token punctuation">;</span>

	<span class="token annotation punctuation">@ApiModelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;就诊人名称&quot;</span><span class="token punctuation">)</span>
	<span class="token annotation punctuation">@TableField</span><span class="token punctuation">(</span><span class="token string">&quot;patient_name&quot;</span><span class="token punctuation">)</span>
	<span class="token keyword">private</span> <span class="token class-name">String</span> patientName<span class="token punctuation">;</span>

	<span class="token annotation punctuation">@ApiModelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;就诊人手机&quot;</span><span class="token punctuation">)</span>
	<span class="token annotation punctuation">@TableField</span><span class="token punctuation">(</span><span class="token string">&quot;patient_phone&quot;</span><span class="token punctuation">)</span>
	<span class="token keyword">private</span> <span class="token class-name">String</span> patientPhone<span class="token punctuation">;</span>

	<span class="token annotation punctuation">@ApiModelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;预约记录唯一标识（医院预约记录主键）&quot;</span><span class="token punctuation">)</span>
	<span class="token annotation punctuation">@TableField</span><span class="token punctuation">(</span><span class="token string">&quot;hos_record_id&quot;</span><span class="token punctuation">)</span>
	<span class="token keyword">private</span> <span class="token class-name">String</span> hosRecordId<span class="token punctuation">;</span>

	<span class="token annotation punctuation">@ApiModelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;预约号序&quot;</span><span class="token punctuation">)</span>
	<span class="token annotation punctuation">@TableField</span><span class="token punctuation">(</span><span class="token string">&quot;number&quot;</span><span class="token punctuation">)</span>
	<span class="token keyword">private</span> <span class="token class-name">Integer</span> number<span class="token punctuation">;</span>

	<span class="token annotation punctuation">@ApiModelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;建议取号时间&quot;</span><span class="token punctuation">)</span>
	<span class="token annotation punctuation">@TableField</span><span class="token punctuation">(</span><span class="token string">&quot;fetch_time&quot;</span><span class="token punctuation">)</span>
	<span class="token keyword">private</span> <span class="token class-name">String</span> fetchTime<span class="token punctuation">;</span>

	<span class="token annotation punctuation">@ApiModelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;取号地点&quot;</span><span class="token punctuation">)</span>
	<span class="token annotation punctuation">@TableField</span><span class="token punctuation">(</span><span class="token string">&quot;fetch_address&quot;</span><span class="token punctuation">)</span>
	<span class="token keyword">private</span> <span class="token class-name">String</span> fetchAddress<span class="token punctuation">;</span>

	<span class="token annotation punctuation">@ApiModelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;医事服务费&quot;</span><span class="token punctuation">)</span>
	<span class="token annotation punctuation">@TableField</span><span class="token punctuation">(</span><span class="token string">&quot;amount&quot;</span><span class="token punctuation">)</span>
	<span class="token keyword">private</span> <span class="token class-name">BigDecimal</span> amount<span class="token punctuation">;</span>

	<span class="token annotation punctuation">@ApiModelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;退号时间&quot;</span><span class="token punctuation">)</span>
	<span class="token annotation punctuation">@JsonFormat</span><span class="token punctuation">(</span>pattern <span class="token operator">=</span> <span class="token string">&quot;yyyy-MM-dd HH:mm&quot;</span><span class="token punctuation">)</span>
	<span class="token annotation punctuation">@TableField</span><span class="token punctuation">(</span><span class="token string">&quot;quit_time&quot;</span><span class="token punctuation">)</span>
	<span class="token keyword">private</span> <span class="token class-name">Date</span> quitTime<span class="token punctuation">;</span>

	<span class="token annotation punctuation">@ApiModelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;订单状态&quot;</span><span class="token punctuation">)</span>
	<span class="token annotation punctuation">@TableField</span><span class="token punctuation">(</span><span class="token string">&quot;order_status&quot;</span><span class="token punctuation">)</span>
	<span class="token keyword">private</span> <span class="token class-name">Integer</span> orderStatus<span class="token punctuation">;</span>

<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br><span class="line-number">41</span><br><span class="line-number">42</span><br><span class="line-number">43</span><br><span class="line-number">44</span><br><span class="line-number">45</span><br><span class="line-number">46</span><br><span class="line-number">47</span><br><span class="line-number">48</span><br><span class="line-number">49</span><br><span class="line-number">50</span><br><span class="line-number">51</span><br><span class="line-number">52</span><br><span class="line-number">53</span><br><span class="line-number">54</span><br><span class="line-number">55</span><br><span class="line-number">56</span><br><span class="line-number">57</span><br><span class="line-number">58</span><br><span class="line-number">59</span><br><span class="line-number">60</span><br><span class="line-number">61</span><br><span class="line-number">62</span><br><span class="line-number">63</span><br><span class="line-number">64</span><br><span class="line-number">65</span><br><span class="line-number">66</span><br><span class="line-number">67</span><br><span class="line-number">68</span><br><span class="line-number">69</span><br><span class="line-number">70</span><br><span class="line-number">71</span><br><span class="line-number">72</span><br><span class="line-number">73</span><br><span class="line-number">74</span><br><span class="line-number">75</span><br><span class="line-number">76</span><br><span class="line-number">77</span><br><span class="line-number">78</span><br><span class="line-number">79</span><br><span class="line-number">80</span><br><span class="line-number">81</span><br><span class="line-number">82</span><br><span class="line-number">83</span><br><span class="line-number">84</span><br><span class="line-number">85</span><br><span class="line-number">86</span><br><span class="line-number">87</span><br><span class="line-number">88</span><br><span class="line-number">89</span><br><span class="line-number">90</span><br><span class="line-number">91</span><br><span class="line-number">92</span><br><span class="line-number">93</span><br><span class="line-number">94</span><br><span class="line-number">95</span><br><span class="line-number">96</span><br><span class="line-number">97</span><br><span class="line-number">98</span><br><span class="line-number">99</span><br><span class="line-number">100</span><br><span class="line-number">101</span><br><span class="line-number">102</span><br><span class="line-number">103</span><br></div></div><p>添加订单枚举类<code>com.stt.yygh.enums.order.OrderStatusEnum</code>，用于枚举订单的状态</p> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>enums</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">ArrayList</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">HashMap</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">List</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">Map</span><span class="token punctuation">;</span>

<span class="token keyword">public</span> <span class="token keyword">enum</span> <span class="token class-name">OrderStatusEnum</span> <span class="token punctuation">{</span>
    <span class="token function">UNPAID</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">,</span><span class="token string">&quot;预约成功，待支付&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">PAID</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">,</span><span class="token string">&quot;已支付&quot;</span> <span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">GET_NUMBER</span><span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token string">&quot;已取号&quot;</span> <span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token function">CANCLE</span><span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">,</span><span class="token string">&quot;取消预约&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
    <span class="token punctuation">;</span>

    <span class="token keyword">private</span> <span class="token class-name">Integer</span> status<span class="token punctuation">;</span>
    <span class="token keyword">private</span> <span class="token class-name">String</span> comment <span class="token punctuation">;</span>

    <span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token class-name">String</span> <span class="token function">getStatusNameByStatus</span><span class="token punctuation">(</span><span class="token class-name">Integer</span> status<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token class-name">OrderStatusEnum</span> arrObj<span class="token punctuation">[</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token class-name">OrderStatusEnum</span><span class="token punctuation">.</span><span class="token function">values</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token class-name">OrderStatusEnum</span> obj <span class="token operator">:</span> arrObj<span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span>status<span class="token punctuation">.</span><span class="token function">intValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">==</span> obj<span class="token punctuation">.</span><span class="token function">getStatus</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">intValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                <span class="token keyword">return</span> obj<span class="token punctuation">.</span><span class="token function">getComment</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
        <span class="token punctuation">}</span>
        <span class="token keyword">return</span> <span class="token string">&quot;&quot;</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">Map</span><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span><span class="token class-name">Object</span><span class="token punctuation">&gt;</span><span class="token punctuation">&gt;</span></span> <span class="token function">getStatusList</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">Map</span><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span><span class="token class-name">Object</span><span class="token punctuation">&gt;</span><span class="token punctuation">&gt;</span></span> list <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ArrayList</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">OrderStatusEnum</span> arrObj<span class="token punctuation">[</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token class-name">OrderStatusEnum</span><span class="token punctuation">.</span><span class="token function">values</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token class-name">OrderStatusEnum</span> obj <span class="token operator">:</span> arrObj<span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token class-name">Map</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span><span class="token class-name">Object</span><span class="token punctuation">&gt;</span></span> map <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">HashMap</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            map<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">&quot;status&quot;</span><span class="token punctuation">,</span> obj<span class="token punctuation">.</span><span class="token function">getStatus</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            map<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">&quot;comment&quot;</span><span class="token punctuation">,</span> obj<span class="token punctuation">.</span><span class="token function">getComment</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            list<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>map<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token keyword">return</span> list<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token class-name">OrderStatusEnum</span><span class="token punctuation">(</span><span class="token class-name">Integer</span> status<span class="token punctuation">,</span> <span class="token class-name">String</span> comment <span class="token punctuation">)</span><span class="token punctuation">{</span>
        <span class="token keyword">this</span><span class="token punctuation">.</span>comment<span class="token operator">=</span>comment<span class="token punctuation">;</span>
        <span class="token keyword">this</span><span class="token punctuation">.</span>status <span class="token operator">=</span> status<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">public</span> <span class="token class-name">String</span> <span class="token function">getComment</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> comment<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">setComment</span><span class="token punctuation">(</span><span class="token class-name">String</span> comment<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">this</span><span class="token punctuation">.</span>comment <span class="token operator">=</span> comment<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">public</span> <span class="token class-name">Integer</span> <span class="token function">getStatus</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> status<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">setStatus</span><span class="token punctuation">(</span><span class="token class-name">Integer</span> status<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">this</span><span class="token punctuation">.</span>status <span class="token operator">=</span> status<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br><span class="line-number">41</span><br><span class="line-number">42</span><br><span class="line-number">43</span><br><span class="line-number">44</span><br><span class="line-number">45</span><br><span class="line-number">46</span><br><span class="line-number">47</span><br><span class="line-number">48</span><br><span class="line-number">49</span><br><span class="line-number">50</span><br><span class="line-number">51</span><br><span class="line-number">52</span><br><span class="line-number">53</span><br><span class="line-number">54</span><br><span class="line-number">55</span><br><span class="line-number">56</span><br><span class="line-number">57</span><br><span class="line-number">58</span><br><span class="line-number">59</span><br><span class="line-number">60</span><br></div></div><h3 id="添加mapper"><a href="#添加mapper" class="header-anchor">#</a> 添加mapper</h3> <p>在 <code>service-order</code>模块中创建<code>com.stt.yygh.order.mapper.OrderInfoMapper</code>类</p> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>order<span class="token punctuation">.</span>mapper</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>baomidou<span class="token punctuation">.</span>mybatisplus<span class="token punctuation">.</span>core<span class="token punctuation">.</span>mapper<span class="token punctuation">.</span></span><span class="token class-name">BaseMapper</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>model<span class="token punctuation">.</span>order<span class="token punctuation">.</span></span><span class="token class-name">OrderInfo</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>apache<span class="token punctuation">.</span>ibatis<span class="token punctuation">.</span>annotations<span class="token punctuation">.</span></span><span class="token class-name">Mapper</span><span class="token punctuation">;</span>

<span class="token annotation punctuation">@Mapper</span>
<span class="token keyword">public</span> <span class="token keyword">interface</span> <span class="token class-name">OrderInfoMapper</span> <span class="token keyword">extends</span> <span class="token class-name">BaseMapper</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">OrderInfo</span><span class="token punctuation">&gt;</span></span> <span class="token punctuation">{</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div><h3 id="添加service以及实现类"><a href="#添加service以及实现类" class="header-anchor">#</a> 添加service以及实现类</h3> <p>在 <code>service-order</code>模块中创建<code>com.stt.yygh.order.service.OrderService</code>类</p> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>order<span class="token punctuation">.</span>service</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>baomidou<span class="token punctuation">.</span>mybatisplus<span class="token punctuation">.</span>extension<span class="token punctuation">.</span>service<span class="token punctuation">.</span></span><span class="token class-name">IService</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>model<span class="token punctuation">.</span>order<span class="token punctuation">.</span></span><span class="token class-name">OrderInfo</span><span class="token punctuation">;</span>

<span class="token keyword">public</span> <span class="token keyword">interface</span> <span class="token class-name">OrderService</span> <span class="token keyword">extends</span> <span class="token class-name">IService</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">OrderInfo</span><span class="token punctuation">&gt;</span></span> <span class="token punctuation">{</span>
    <span class="token comment">//保存订单</span>
    <span class="token class-name">Long</span> <span class="token function">saveOrder</span><span class="token punctuation">(</span><span class="token class-name">String</span> scheduleId<span class="token punctuation">,</span> <span class="token class-name">Long</span> patientId<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div><p>实现该接口</p> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>order<span class="token punctuation">.</span>service<span class="token punctuation">.</span>impl</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>baomidou<span class="token punctuation">.</span>mybatisplus<span class="token punctuation">.</span>extension<span class="token punctuation">.</span>service<span class="token punctuation">.</span>impl<span class="token punctuation">.</span></span><span class="token class-name">ServiceImpl</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>model<span class="token punctuation">.</span>order<span class="token punctuation">.</span></span><span class="token class-name">OrderInfo</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>order<span class="token punctuation">.</span>mapper<span class="token punctuation">.</span></span><span class="token class-name">OrderInfoMapper</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>order<span class="token punctuation">.</span>service<span class="token punctuation">.</span></span><span class="token class-name">OrderService</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>stereotype<span class="token punctuation">.</span></span><span class="token class-name">Service</span><span class="token punctuation">;</span>

<span class="token annotation punctuation">@Service</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">OrderServiceImpl</span> <span class="token keyword">extends</span> <span class="token class-name">ServiceImpl</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">OrderInfoMapper</span><span class="token punctuation">,</span> <span class="token class-name">OrderInfo</span><span class="token punctuation">&gt;</span></span> <span class="token keyword">implements</span> <span class="token class-name">OrderService</span> <span class="token punctuation">{</span>
    <span class="token annotation punctuation">@Override</span>
    <span class="token keyword">public</span> <span class="token class-name">Long</span> <span class="token function">saveOrder</span><span class="token punctuation">(</span><span class="token class-name">String</span> scheduleId<span class="token punctuation">,</span> <span class="token class-name">Long</span> patientId<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> <span class="token keyword">null</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br></div></div><h3 id="添加controller"><a href="#添加controller" class="header-anchor">#</a> 添加controller</h3> <p>在 <code>service-order</code>模块中创建<code>com.stt.yygh.order.controller.OrderApiController</code>类</p> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>order<span class="token punctuation">.</span>controller</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>common<span class="token punctuation">.</span>result<span class="token punctuation">.</span></span><span class="token class-name">Result</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>order<span class="token punctuation">.</span>service<span class="token punctuation">.</span></span><span class="token class-name">OrderService</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">io<span class="token punctuation">.</span>swagger<span class="token punctuation">.</span>annotations<span class="token punctuation">.</span></span><span class="token class-name">Api</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">io<span class="token punctuation">.</span>swagger<span class="token punctuation">.</span>annotations<span class="token punctuation">.</span></span><span class="token class-name">ApiOperation</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">io<span class="token punctuation">.</span>swagger<span class="token punctuation">.</span>annotations<span class="token punctuation">.</span></span><span class="token class-name">ApiParam</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>beans<span class="token punctuation">.</span>factory<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span></span><span class="token class-name">Autowired</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>web<span class="token punctuation">.</span>bind<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span></span><span class="token class-name">PathVariable</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>web<span class="token punctuation">.</span>bind<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span></span><span class="token class-name">PostMapping</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>web<span class="token punctuation">.</span>bind<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span></span><span class="token class-name">RequestMapping</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>web<span class="token punctuation">.</span>bind<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span></span><span class="token class-name">RestController</span><span class="token punctuation">;</span>

<span class="token annotation punctuation">@Api</span><span class="token punctuation">(</span>tags <span class="token operator">=</span> <span class="token string">&quot;订单接口&quot;</span><span class="token punctuation">)</span>
<span class="token annotation punctuation">@RestController</span>
<span class="token annotation punctuation">@RequestMapping</span><span class="token punctuation">(</span><span class="token string">&quot;/api/order/orderInfo&quot;</span><span class="token punctuation">)</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">OrderApiController</span> <span class="token punctuation">{</span>

    <span class="token annotation punctuation">@Autowired</span>
    <span class="token keyword">private</span> <span class="token class-name">OrderService</span> service<span class="token punctuation">;</span>

    <span class="token annotation punctuation">@ApiOperation</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;创建订单&quot;</span><span class="token punctuation">)</span>
    <span class="token annotation punctuation">@PostMapping</span><span class="token punctuation">(</span><span class="token string">&quot;auth/submitOrder/{scheduleId}/{patientId}&quot;</span><span class="token punctuation">)</span>
    <span class="token keyword">public</span> <span class="token class-name">Result</span> <span class="token function">submitOrder</span><span class="token punctuation">(</span><span class="token annotation punctuation">@ApiParam</span><span class="token punctuation">(</span>name <span class="token operator">=</span> <span class="token string">&quot;scheduleId&quot;</span><span class="token punctuation">,</span> value <span class="token operator">=</span> <span class="token string">&quot;排班id&quot;</span><span class="token punctuation">,</span> required <span class="token operator">=</span> <span class="token boolean">true</span><span class="token punctuation">)</span>
                              <span class="token annotation punctuation">@PathVariable</span> <span class="token class-name">String</span> scheduleId<span class="token punctuation">,</span>
                              <span class="token annotation punctuation">@ApiParam</span><span class="token punctuation">(</span>name <span class="token operator">=</span> <span class="token string">&quot;patientId&quot;</span><span class="token punctuation">,</span> value <span class="token operator">=</span> <span class="token string">&quot;就诊人id&quot;</span><span class="token punctuation">,</span> required <span class="token operator">=</span> <span class="token boolean">true</span><span class="token punctuation">)</span>
                              <span class="token annotation punctuation">@PathVariable</span> <span class="token class-name">Long</span> patientId<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> <span class="token class-name">Result</span><span class="token punctuation">.</span><span class="token function">ok</span><span class="token punctuation">(</span>service<span class="token punctuation">.</span><span class="token function">saveOrder</span><span class="token punctuation">(</span>scheduleId<span class="token punctuation">,</span> patientId<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br></div></div><h2 id="封装feign获取就诊人信息"><a href="#封装feign获取就诊人信息" class="header-anchor">#</a> 封装feign获取就诊人信息</h2> <h3 id="添加获取就诊人信息接口-service-user"><a href="#添加获取就诊人信息接口-service-user" class="header-anchor">#</a> 添加获取就诊人信息接口 service-user</h3> <p>在 <code>service-user</code>中的<code>PatientApiController</code>类添加方法 <code>getPatientOrder</code></p> <p>注意：返回值类型是 <code>Patient</code>，同时接口的path包含 <code>inner</code> ，在<code>service-gateway</code>中针对该path路径做了屏蔽，不允许从gateway服务访问</p> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>user<span class="token punctuation">.</span>controller</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>common<span class="token punctuation">.</span>result<span class="token punctuation">.</span></span><span class="token class-name">Result</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>common<span class="token punctuation">.</span>utils<span class="token punctuation">.</span></span><span class="token class-name">AuthContextHolder</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>model<span class="token punctuation">.</span>user<span class="token punctuation">.</span></span><span class="token class-name">Patient</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>user<span class="token punctuation">.</span>service<span class="token punctuation">.</span></span><span class="token class-name">PatientService</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">io<span class="token punctuation">.</span>swagger<span class="token punctuation">.</span>annotations<span class="token punctuation">.</span></span><span class="token class-name">ApiOperation</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">io<span class="token punctuation">.</span>swagger<span class="token punctuation">.</span>annotations<span class="token punctuation">.</span></span><span class="token class-name">ApiParam</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>beans<span class="token punctuation">.</span>factory<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span></span><span class="token class-name">Autowired</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>web<span class="token punctuation">.</span>bind<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span></span><span class="token operator">*</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token namespace">javax<span class="token punctuation">.</span>servlet<span class="token punctuation">.</span>http<span class="token punctuation">.</span></span><span class="token class-name">HttpServletRequest</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">List</span><span class="token punctuation">;</span>

<span class="token comment">//就诊人管理接口</span>
<span class="token annotation punctuation">@RestController</span>
<span class="token annotation punctuation">@RequestMapping</span><span class="token punctuation">(</span><span class="token string">&quot;/api/user/patient&quot;</span><span class="token punctuation">)</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">PatientApiController</span> <span class="token punctuation">{</span>

    <span class="token annotation punctuation">@Autowired</span>
    <span class="token keyword">private</span> <span class="token class-name">PatientService</span> service<span class="token punctuation">;</span>

<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
    <span class="token annotation punctuation">@ApiOperation</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;获取就诊人&quot;</span><span class="token punctuation">)</span>
    <span class="token annotation punctuation">@GetMapping</span><span class="token punctuation">(</span><span class="token string">&quot;inner/get/{id}&quot;</span><span class="token punctuation">)</span>
    <span class="token keyword">public</span> <span class="token class-name">Patient</span> <span class="token function">getPatientInfo</span><span class="token punctuation">(</span><span class="token annotation punctuation">@ApiParam</span><span class="token punctuation">(</span>name <span class="token operator">=</span> <span class="token string">&quot;id&quot;</span><span class="token punctuation">,</span> value <span class="token operator">=</span> <span class="token string">&quot;就诊人id&quot;</span><span class="token punctuation">,</span> required <span class="token operator">=</span> <span class="token boolean">true</span><span class="token punctuation">)</span>
                                   <span class="token annotation punctuation">@PathVariable</span><span class="token punctuation">(</span><span class="token string">&quot;id&quot;</span><span class="token punctuation">)</span> <span class="token class-name">Long</span> id<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> service<span class="token punctuation">.</span><span class="token function">getById</span><span class="token punctuation">(</span>id<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br></div></div><h3 id="搭建service-user-client模块"><a href="#搭建service-user-client模块" class="header-anchor">#</a> 搭建service-user-client模块</h3> <p>通过feign调用service-user模块，获取就诊人信息，调用上面的接口</p> <p>搭建过程如service-cmn-client模块</p> <h4 id="修改pom-2"><a href="#修改pom-2" class="header-anchor">#</a> 修改pom</h4> <div class="language-xml line-numbers-mode"><pre class="language-xml"><code><span class="token prolog">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>project</span> <span class="token attr-name">xmlns</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://maven.apache.org/POM/4.0.0<span class="token punctuation">&quot;</span></span>
         <span class="token attr-name"><span class="token namespace">xmlns:</span>xsi</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://www.w3.org/2001/XMLSchema-instance<span class="token punctuation">&quot;</span></span>
         <span class="token attr-name"><span class="token namespace">xsi:</span>schemaLocation</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>parent</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>service-client<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>com.stt.yygh<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>1.0<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>parent</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>modelVersion</span><span class="token punctuation">&gt;</span></span>4.0.0<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>modelVersion</span><span class="token punctuation">&gt;</span></span>

    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>service-user-client<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>packaging</span><span class="token punctuation">&gt;</span></span>jar<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>packaging</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>1.0<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>name</span><span class="token punctuation">&gt;</span></span>service-user-client<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>name</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>description</span><span class="token punctuation">&gt;</span></span>service-user-client<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>description</span><span class="token punctuation">&gt;</span></span>
    
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>properties</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>maven.compiler.source</span><span class="token punctuation">&gt;</span></span>8<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>maven.compiler.source</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>maven.compiler.target</span><span class="token punctuation">&gt;</span></span>8<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>maven.compiler.target</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>properties</span><span class="token punctuation">&gt;</span></span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>project</span><span class="token punctuation">&gt;</span></span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br></div></div><h4 id="添加feign接口类"><a href="#添加feign接口类" class="header-anchor">#</a> 添加feign接口类</h4> <p>创建 <code>com.stt.yygh.user.client.PatientFeignClient</code> 类，并添加如下path</p> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>user<span class="token punctuation">.</span>client</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>model<span class="token punctuation">.</span>user<span class="token punctuation">.</span></span><span class="token class-name">Patient</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>cloud<span class="token punctuation">.</span>openfeign<span class="token punctuation">.</span></span><span class="token class-name">FeignClient</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>stereotype<span class="token punctuation">.</span></span><span class="token class-name">Component</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>web<span class="token punctuation">.</span>bind<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span></span><span class="token class-name">GetMapping</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>web<span class="token punctuation">.</span>bind<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span></span><span class="token class-name">PathVariable</span><span class="token punctuation">;</span>

<span class="token annotation punctuation">@FeignClient</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;service-user&quot;</span><span class="token punctuation">)</span>
<span class="token annotation punctuation">@Component</span>
<span class="token keyword">public</span> <span class="token keyword">interface</span> <span class="token class-name">PatientFeignClient</span> <span class="token punctuation">{</span>

    <span class="token comment">//获取就诊人信息</span>
    <span class="token annotation punctuation">@GetMapping</span><span class="token punctuation">(</span><span class="token string">&quot;/api/user/patient/inner/get/{id}&quot;</span><span class="token punctuation">)</span>
    <span class="token class-name">Patient</span> <span class="token function">getPatientInfo</span><span class="token punctuation">(</span><span class="token annotation punctuation">@PathVariable</span><span class="token punctuation">(</span><span class="token string">&quot;id&quot;</span><span class="token punctuation">)</span> <span class="token class-name">Long</span> id<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br></div></div><h2 id="封装feign获取排班下单信息"><a href="#封装feign获取排班下单信息" class="header-anchor">#</a> 封装feign获取排班下单信息</h2> <h3 id="添加排班下单信息-model"><a href="#添加排班下单信息-model" class="header-anchor">#</a> 添加排班下单信息 model</h3> <p>在<code>model</code>模块中添加<code>com.stt.yygh.vo.hosp.ScheduleOrderVo</code> 类</p> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>vo<span class="token punctuation">.</span>hosp</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token namespace">io<span class="token punctuation">.</span>swagger<span class="token punctuation">.</span>annotations<span class="token punctuation">.</span></span><span class="token class-name">ApiModel</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">io<span class="token punctuation">.</span>swagger<span class="token punctuation">.</span>annotations<span class="token punctuation">.</span></span><span class="token class-name">ApiModelProperty</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">lombok<span class="token punctuation">.</span></span><span class="token class-name">Data</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token namespace">java<span class="token punctuation">.</span>math<span class="token punctuation">.</span></span><span class="token class-name">BigDecimal</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">Date</span><span class="token punctuation">;</span>

<span class="token annotation punctuation">@Data</span>
<span class="token annotation punctuation">@ApiModel</span><span class="token punctuation">(</span>description <span class="token operator">=</span> <span class="token string">&quot;Schedule&quot;</span><span class="token punctuation">)</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">ScheduleOrderVo</span> <span class="token punctuation">{</span>

	<span class="token annotation punctuation">@ApiModelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;医院编号&quot;</span><span class="token punctuation">)</span>
	<span class="token keyword">private</span> <span class="token class-name">String</span> hoscode<span class="token punctuation">;</span>

	<span class="token annotation punctuation">@ApiModelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;医院名称&quot;</span><span class="token punctuation">)</span>
	<span class="token keyword">private</span> <span class="token class-name">String</span> hosname<span class="token punctuation">;</span>

	<span class="token annotation punctuation">@ApiModelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;科室编号&quot;</span><span class="token punctuation">)</span>
	<span class="token keyword">private</span> <span class="token class-name">String</span> depcode<span class="token punctuation">;</span>

	<span class="token annotation punctuation">@ApiModelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;科室名称&quot;</span><span class="token punctuation">)</span>
	<span class="token keyword">private</span> <span class="token class-name">String</span> depname<span class="token punctuation">;</span>

	<span class="token annotation punctuation">@ApiModelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;排班编号（医院自己的排班主键）&quot;</span><span class="token punctuation">)</span>
	<span class="token keyword">private</span> <span class="token class-name">String</span> hosScheduleId<span class="token punctuation">;</span>

	<span class="token annotation punctuation">@ApiModelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;医生职称&quot;</span><span class="token punctuation">)</span>
	<span class="token keyword">private</span> <span class="token class-name">String</span> title<span class="token punctuation">;</span>

	<span class="token annotation punctuation">@ApiModelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;安排日期&quot;</span><span class="token punctuation">)</span>
	<span class="token keyword">private</span> <span class="token class-name">Date</span> reserveDate<span class="token punctuation">;</span>

	<span class="token annotation punctuation">@ApiModelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;剩余预约数&quot;</span><span class="token punctuation">)</span>
	<span class="token keyword">private</span> <span class="token class-name">Integer</span> availableNumber<span class="token punctuation">;</span>

	<span class="token annotation punctuation">@ApiModelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;安排时间（0：上午 1：下午）&quot;</span><span class="token punctuation">)</span>
	<span class="token keyword">private</span> <span class="token class-name">Integer</span> reserveTime<span class="token punctuation">;</span>

	<span class="token annotation punctuation">@ApiModelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;医事服务费&quot;</span><span class="token punctuation">)</span>
	<span class="token keyword">private</span> <span class="token class-name">BigDecimal</span> amount<span class="token punctuation">;</span>

	<span class="token annotation punctuation">@ApiModelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;退号时间&quot;</span><span class="token punctuation">)</span>
	<span class="token keyword">private</span> <span class="token class-name">Date</span> quitTime<span class="token punctuation">;</span>

	<span class="token annotation punctuation">@ApiModelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;挂号开始时间&quot;</span><span class="token punctuation">)</span>
	<span class="token keyword">private</span> <span class="token class-name">Date</span> startTime<span class="token punctuation">;</span>

	<span class="token annotation punctuation">@ApiModelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;挂号结束时间&quot;</span><span class="token punctuation">)</span>
	<span class="token keyword">private</span> <span class="token class-name">Date</span> endTime<span class="token punctuation">;</span>

	<span class="token annotation punctuation">@ApiModelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;当天停止挂号时间&quot;</span><span class="token punctuation">)</span>
	<span class="token keyword">private</span> <span class="token class-name">Date</span> stopTime<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br><span class="line-number">41</span><br><span class="line-number">42</span><br><span class="line-number">43</span><br><span class="line-number">44</span><br><span class="line-number">45</span><br><span class="line-number">46</span><br><span class="line-number">47</span><br><span class="line-number">48</span><br><span class="line-number">49</span><br><span class="line-number">50</span><br><span class="line-number">51</span><br><span class="line-number">52</span><br><span class="line-number">53</span><br><span class="line-number">54</span><br><span class="line-number">55</span><br></div></div><h3 id="添加获取排班下单信息接口-service-hosp"><a href="#添加获取排班下单信息接口-service-hosp" class="header-anchor">#</a> 添加获取排班下单信息接口 service-hosp</h3> <p>在<code>service-hosp</code>模块中添加如下操作</p> <h4 id="添加service接口与实现"><a href="#添加service接口与实现" class="header-anchor">#</a> 添加service接口与实现</h4> <p>在ScheduleService类添加接口</p> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>hosp<span class="token punctuation">.</span>service</span><span class="token punctuation">;</span>
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>vo<span class="token punctuation">.</span>hosp<span class="token punctuation">.</span></span><span class="token class-name">ScheduleOrderVo</span><span class="token punctuation">;</span>
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token keyword">public</span> <span class="token keyword">interface</span> <span class="token class-name">ScheduleService</span> <span class="token punctuation">{</span>
 <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
    <span class="token comment">//根据排班id获取预约下单数据</span>
    <span class="token class-name">ScheduleOrderVo</span> <span class="token function">getScheduleOrderVo</span><span class="token punctuation">(</span><span class="token class-name">String</span> scheduleId<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div><p>添加对应的实现</p> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>hosp<span class="token punctuation">.</span>service<span class="token punctuation">.</span>impl</span><span class="token punctuation">;</span>
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token annotation punctuation">@Service</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">ScheduleServiceImpl</span> <span class="token keyword">implements</span> <span class="token class-name">ScheduleService</span> <span class="token punctuation">{</span>
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
    <span class="token comment">//根据排班id获取预约下单数据</span>
    <span class="token annotation punctuation">@Override</span>
    <span class="token keyword">public</span> <span class="token class-name">ScheduleOrderVo</span> <span class="token function">getScheduleOrderVo</span><span class="token punctuation">(</span><span class="token class-name">String</span> scheduleId<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token comment">//排班信息</span>
        <span class="token class-name">Schedule</span> schedule <span class="token operator">=</span> <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">getById</span><span class="token punctuation">(</span>scheduleId<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token class-name">Objects</span><span class="token punctuation">.</span><span class="token function">isNull</span><span class="token punctuation">(</span>schedule<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token keyword">throw</span> <span class="token keyword">new</span> <span class="token class-name">YyghException</span><span class="token punctuation">(</span><span class="token class-name">ResultCodeEnum</span><span class="token punctuation">.</span>DATA_ERROR<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token comment">//获取预约规则信息</span>
        <span class="token class-name">Hospital</span> hospital <span class="token operator">=</span> hospitalService<span class="token punctuation">.</span><span class="token function">getByHoscode</span><span class="token punctuation">(</span>schedule<span class="token punctuation">.</span><span class="token function">getHoscode</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token class-name">Objects</span><span class="token punctuation">.</span><span class="token function">isNull</span><span class="token punctuation">(</span>hospital<span class="token punctuation">)</span> <span class="token operator">||</span> <span class="token class-name">Objects</span><span class="token punctuation">.</span><span class="token function">isNull</span><span class="token punctuation">(</span>hospital<span class="token punctuation">.</span><span class="token function">getBookingRule</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token keyword">throw</span> <span class="token keyword">new</span> <span class="token class-name">YyghException</span><span class="token punctuation">(</span><span class="token class-name">ResultCodeEnum</span><span class="token punctuation">.</span>DATA_ERROR<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token keyword">return</span> <span class="token function">parseScheduleOrderVo</span><span class="token punctuation">(</span>schedule<span class="token punctuation">,</span> hospital<span class="token punctuation">.</span><span class="token function">getBookingRule</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">private</span> <span class="token class-name">ScheduleOrderVo</span> <span class="token function">parseScheduleOrderVo</span><span class="token punctuation">(</span><span class="token class-name">Schedule</span> schedule<span class="token punctuation">,</span> <span class="token class-name">BookingRule</span> rule<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token class-name">ScheduleOrderVo</span> re <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">ScheduleOrderVo</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        re<span class="token punctuation">.</span><span class="token function">setHoscode</span><span class="token punctuation">(</span>schedule<span class="token punctuation">.</span><span class="token function">getHoscode</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        re<span class="token punctuation">.</span><span class="token function">setDepcode</span><span class="token punctuation">(</span>schedule<span class="token punctuation">.</span><span class="token function">getDepcode</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        re<span class="token punctuation">.</span><span class="token function">setHosname</span><span class="token punctuation">(</span>hospitalService<span class="token punctuation">.</span><span class="token function">getHospName</span><span class="token punctuation">(</span>schedule<span class="token punctuation">.</span><span class="token function">getHoscode</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        re<span class="token punctuation">.</span><span class="token function">setDepname</span><span class="token punctuation">(</span>departmentService<span class="token punctuation">.</span><span class="token function">getDepName</span><span class="token punctuation">(</span>schedule<span class="token punctuation">.</span><span class="token function">getHoscode</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> schedule<span class="token punctuation">.</span><span class="token function">getDepcode</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        re<span class="token punctuation">.</span><span class="token function">setHosScheduleId</span><span class="token punctuation">(</span>schedule<span class="token punctuation">.</span><span class="token function">getHosScheduleId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        re<span class="token punctuation">.</span><span class="token function">setAvailableNumber</span><span class="token punctuation">(</span>schedule<span class="token punctuation">.</span><span class="token function">getAvailableNumber</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        re<span class="token punctuation">.</span><span class="token function">setTitle</span><span class="token punctuation">(</span>schedule<span class="token punctuation">.</span><span class="token function">getTitle</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        re<span class="token punctuation">.</span><span class="token function">setReserveDate</span><span class="token punctuation">(</span>schedule<span class="token punctuation">.</span><span class="token function">getWorkDate</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        re<span class="token punctuation">.</span><span class="token function">setReserveTime</span><span class="token punctuation">(</span>schedule<span class="token punctuation">.</span><span class="token function">getWorkTime</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        re<span class="token punctuation">.</span><span class="token function">setAmount</span><span class="token punctuation">(</span>schedule<span class="token punctuation">.</span><span class="token function">getAmount</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//退号截止天数（如：就诊前一天为-1，当天为0）</span>
        re<span class="token punctuation">.</span><span class="token function">setQuitTime</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">getDateTime</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">DateTime</span><span class="token punctuation">(</span>schedule<span class="token punctuation">.</span><span class="token function">getWorkDate</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">plusDays</span><span class="token punctuation">(</span>rule<span class="token punctuation">.</span><span class="token function">getQuitDay</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">toDate</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> rule<span class="token punctuation">.</span><span class="token function">getQuitTime</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">toDate</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//预约开始时间</span>
        re<span class="token punctuation">.</span><span class="token function">setStartTime</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">getDateTime</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">Date</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> rule<span class="token punctuation">.</span><span class="token function">getReleaseTime</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">toDate</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//预约截止时间</span>
        re<span class="token punctuation">.</span><span class="token function">setEndTime</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">getDateTime</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">DateTime</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">plusDays</span><span class="token punctuation">(</span>rule<span class="token punctuation">.</span><span class="token function">getCycle</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">toDate</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> rule<span class="token punctuation">.</span><span class="token function">getStopTime</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">toDate</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//当天停止挂号时间</span>
        re<span class="token punctuation">.</span><span class="token function">setStopTime</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">getDateTime</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">Date</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> rule<span class="token punctuation">.</span><span class="token function">getStopTime</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">toDate</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">return</span> re<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br><span class="line-number">41</span><br><span class="line-number">42</span><br><span class="line-number">43</span><br><span class="line-number">44</span><br><span class="line-number">45</span><br></div></div><h4 id="添加controller方法"><a href="#添加controller方法" class="header-anchor">#</a> 添加controller方法</h4> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>hosp<span class="token punctuation">.</span>controller</span><span class="token punctuation">;</span>
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>

<span class="token keyword">import</span> <span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">List</span><span class="token punctuation">;</span>

<span class="token annotation punctuation">@Api</span><span class="token punctuation">(</span>tags <span class="token operator">=</span> <span class="token string">&quot;医院管理接口&quot;</span><span class="token punctuation">)</span>
<span class="token annotation punctuation">@RestController</span>
<span class="token annotation punctuation">@RequestMapping</span><span class="token punctuation">(</span><span class="token string">&quot;/api/hosp/hospital&quot;</span><span class="token punctuation">)</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">HospitalApiController</span> <span class="token punctuation">{</span>
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>

    <span class="token annotation punctuation">@Autowired</span>
    <span class="token keyword">private</span> <span class="token class-name">ScheduleService</span> scheduleService<span class="token punctuation">;</span>
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>

    <span class="token annotation punctuation">@ApiOperation</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;根据排班id获取预约下单数据&quot;</span><span class="token punctuation">)</span>
    <span class="token annotation punctuation">@GetMapping</span><span class="token punctuation">(</span><span class="token string">&quot;inner/getScheduleOrderVo/{scheduleId}&quot;</span><span class="token punctuation">)</span>
    <span class="token keyword">public</span> <span class="token class-name">ScheduleOrderVo</span> <span class="token function">getScheduleOrderVo</span><span class="token punctuation">(</span><span class="token annotation punctuation">@ApiParam</span><span class="token punctuation">(</span>name <span class="token operator">=</span> <span class="token string">&quot;scheduleId&quot;</span><span class="token punctuation">,</span> value <span class="token operator">=</span> <span class="token string">&quot;排班id&quot;</span><span class="token punctuation">,</span> required <span class="token operator">=</span> <span class="token boolean">true</span><span class="token punctuation">)</span>
                                              <span class="token annotation punctuation">@PathVariable</span><span class="token punctuation">(</span><span class="token string">&quot;scheduleId&quot;</span><span class="token punctuation">)</span> <span class="token class-name">String</span> scheduleId<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> scheduleService<span class="token punctuation">.</span><span class="token function">getScheduleOrderVo</span><span class="token punctuation">(</span>scheduleId<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br></div></div><h3 id="添加签名信息-model"><a href="#添加签名信息-model" class="header-anchor">#</a> 添加签名信息 model</h3> <p>在<code>model</code>模块中添加<code>com.stt.yygh.vo.hosp.SignInfoVo</code> 类</p> <p>返回医院设置的部分信息</p> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>vo<span class="token punctuation">.</span>hosp</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token namespace">io<span class="token punctuation">.</span>swagger<span class="token punctuation">.</span>annotations<span class="token punctuation">.</span></span><span class="token class-name">ApiModel</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">io<span class="token punctuation">.</span>swagger<span class="token punctuation">.</span>annotations<span class="token punctuation">.</span></span><span class="token class-name">ApiModelProperty</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">lombok<span class="token punctuation">.</span></span><span class="token class-name">Data</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token namespace">java<span class="token punctuation">.</span>io<span class="token punctuation">.</span></span><span class="token class-name">Serializable</span><span class="token punctuation">;</span>

<span class="token annotation punctuation">@Data</span>
<span class="token annotation punctuation">@ApiModel</span><span class="token punctuation">(</span>description <span class="token operator">=</span> <span class="token string">&quot;签名信息&quot;</span><span class="token punctuation">)</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">SignInfoVo</span> <span class="token keyword">implements</span> <span class="token class-name">Serializable</span> <span class="token punctuation">{</span>

    <span class="token keyword">private</span> <span class="token keyword">static</span> <span class="token keyword">final</span> <span class="token keyword">long</span> serialVersionUID <span class="token operator">=</span> <span class="token number">1L</span><span class="token punctuation">;</span>

    <span class="token annotation punctuation">@ApiModelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;api基础路径&quot;</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">String</span> apiUrl<span class="token punctuation">;</span>

    <span class="token annotation punctuation">@ApiModelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;签名秘钥&quot;</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">String</span> signKey<span class="token punctuation">;</span>

<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br></div></div><h3 id="获取下单签名引用信息接口-service-hosp"><a href="#获取下单签名引用信息接口-service-hosp" class="header-anchor">#</a> 获取下单签名引用信息接口 service-hosp</h3> <p>获取医院的签名信息，用于调用医院模拟系统时，给传输的数据添加数字签名，以及应该访问哪个医院系统，进行订单的创建</p> <h4 id="添加service接口与实现-2"><a href="#添加service接口与实现-2" class="header-anchor">#</a> 添加service接口与实现</h4> <p>在<code>com.stt.yygh.hosp.service.HospitalSetService</code>类添加接口</p> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>hosp<span class="token punctuation">.</span>service</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>baomidou<span class="token punctuation">.</span>mybatisplus<span class="token punctuation">.</span>extension<span class="token punctuation">.</span>service<span class="token punctuation">.</span></span><span class="token class-name">IService</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>model<span class="token punctuation">.</span>hosp<span class="token punctuation">.</span></span><span class="token class-name">HospitalSet</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>vo<span class="token punctuation">.</span>hosp<span class="token punctuation">.</span></span><span class="token class-name">SignInfoVo</span><span class="token punctuation">;</span>

<span class="token keyword">public</span> <span class="token keyword">interface</span> <span class="token class-name">HospitalSetService</span> <span class="token keyword">extends</span> <span class="token class-name">IService</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">HospitalSet</span><span class="token punctuation">&gt;</span></span> <span class="token punctuation">{</span>
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
    <span class="token class-name">SignInfoVo</span> <span class="token function">getSignInfoVo</span><span class="token punctuation">(</span><span class="token class-name">String</span> hoscode<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div><p>对应实现</p> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>hosp<span class="token punctuation">.</span>service<span class="token punctuation">.</span>impl</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>baomidou<span class="token punctuation">.</span>mybatisplus<span class="token punctuation">.</span>core<span class="token punctuation">.</span>conditions<span class="token punctuation">.</span>query<span class="token punctuation">.</span></span><span class="token class-name">QueryWrapper</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>baomidou<span class="token punctuation">.</span>mybatisplus<span class="token punctuation">.</span>extension<span class="token punctuation">.</span>service<span class="token punctuation">.</span>impl<span class="token punctuation">.</span></span><span class="token class-name">ServiceImpl</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>common<span class="token punctuation">.</span>exception<span class="token punctuation">.</span></span><span class="token class-name">YyghException</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>common<span class="token punctuation">.</span>result<span class="token punctuation">.</span></span><span class="token class-name">ResultCodeEnum</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>hosp<span class="token punctuation">.</span>mapper<span class="token punctuation">.</span></span><span class="token class-name">HospitalSetMapper</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>hosp<span class="token punctuation">.</span>service<span class="token punctuation">.</span></span><span class="token class-name">HospitalSetService</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>model<span class="token punctuation">.</span>hosp<span class="token punctuation">.</span></span><span class="token class-name">HospitalSet</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>vo<span class="token punctuation">.</span>hosp<span class="token punctuation">.</span></span><span class="token class-name">SignInfoVo</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>stereotype<span class="token punctuation">.</span></span><span class="token class-name">Service</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">Objects</span><span class="token punctuation">;</span>

<span class="token annotation punctuation">@Service</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">HospitalSetServiceImpl</span> <span class="token keyword">extends</span> <span class="token class-name">ServiceImpl</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">HospitalSetMapper</span><span class="token punctuation">,</span> <span class="token class-name">HospitalSet</span><span class="token punctuation">&gt;</span></span> <span class="token keyword">implements</span> <span class="token class-name">HospitalSetService</span> <span class="token punctuation">{</span>
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
    <span class="token comment">//获取医院签名信息</span>
    <span class="token annotation punctuation">@Override</span>
    <span class="token keyword">public</span> <span class="token class-name">SignInfoVo</span> <span class="token function">getSignInfoVo</span><span class="token punctuation">(</span><span class="token class-name">String</span> hoscode<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token class-name">QueryWrapper</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">HospitalSet</span><span class="token punctuation">&gt;</span></span> wrapper <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">QueryWrapper</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        wrapper<span class="token punctuation">.</span><span class="token function">eq</span><span class="token punctuation">(</span><span class="token string">&quot;hoscode&quot;</span><span class="token punctuation">,</span>hoscode<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">HospitalSet</span> hospitalSet <span class="token operator">=</span> baseMapper<span class="token punctuation">.</span><span class="token function">selectOne</span><span class="token punctuation">(</span>wrapper<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">if</span><span class="token punctuation">(</span><span class="token class-name">Objects</span><span class="token punctuation">.</span><span class="token function">isNull</span><span class="token punctuation">(</span>hospitalSet<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token keyword">throw</span> <span class="token keyword">new</span> <span class="token class-name">YyghException</span><span class="token punctuation">(</span><span class="token class-name">ResultCodeEnum</span><span class="token punctuation">.</span>HOSPITAL_OPEN<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token class-name">SignInfoVo</span> signInfoVo <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">SignInfoVo</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        signInfoVo<span class="token punctuation">.</span><span class="token function">setApiUrl</span><span class="token punctuation">(</span>hospitalSet<span class="token punctuation">.</span><span class="token function">getApiUrl</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        signInfoVo<span class="token punctuation">.</span><span class="token function">setSignKey</span><span class="token punctuation">(</span>hospitalSet<span class="token punctuation">.</span><span class="token function">getSignKey</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">return</span> signInfoVo<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br></div></div><h4 id="添加controller方法-2"><a href="#添加controller方法-2" class="header-anchor">#</a> 添加controller方法</h4> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>hosp<span class="token punctuation">.</span>controller</span><span class="token punctuation">;</span>
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token annotation punctuation">@Api</span><span class="token punctuation">(</span>tags <span class="token operator">=</span> <span class="token string">&quot;医院管理接口&quot;</span><span class="token punctuation">)</span>
<span class="token annotation punctuation">@RestController</span>
<span class="token annotation punctuation">@RequestMapping</span><span class="token punctuation">(</span><span class="token string">&quot;/api/hosp/hospital&quot;</span><span class="token punctuation">)</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">HospitalApiController</span> <span class="token punctuation">{</span>
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>  
    <span class="token annotation punctuation">@Autowired</span>
    <span class="token keyword">private</span> <span class="token class-name">HospitalSetService</span> hospitalSetService<span class="token punctuation">;</span>
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
    <span class="token annotation punctuation">@ApiOperation</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;获取医院签名信息&quot;</span><span class="token punctuation">)</span>
    <span class="token annotation punctuation">@GetMapping</span><span class="token punctuation">(</span><span class="token string">&quot;inner/getSignInfoVo/{hoscode}&quot;</span><span class="token punctuation">)</span>
    <span class="token keyword">public</span> <span class="token class-name">SignInfoVo</span> <span class="token function">getSignInfoVo</span><span class="token punctuation">(</span><span class="token annotation punctuation">@ApiParam</span><span class="token punctuation">(</span>name <span class="token operator">=</span> <span class="token string">&quot;hoscode&quot;</span><span class="token punctuation">,</span> value <span class="token operator">=</span> <span class="token string">&quot;医院code&quot;</span><span class="token punctuation">,</span> required <span class="token operator">=</span> <span class="token boolean">true</span><span class="token punctuation">)</span>
            <span class="token annotation punctuation">@PathVariable</span><span class="token punctuation">(</span><span class="token string">&quot;hoscode&quot;</span><span class="token punctuation">)</span> <span class="token class-name">String</span> hoscode<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> hospitalSetService<span class="token punctuation">.</span><span class="token function">getSignInfoVo</span><span class="token punctuation">(</span>hoscode<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br></div></div><h3 id="搭建service-hosp-client模块"><a href="#搭建service-hosp-client模块" class="header-anchor">#</a> 搭建service-hosp-client模块</h3> <p>通过feign调用service-hosp模块，获取排班下单信息，调用上面的接口</p> <p>搭建过程如service-cmn-client模块</p> <h4 id="修改pom-3"><a href="#修改pom-3" class="header-anchor">#</a> 修改pom</h4> <div class="language-xml line-numbers-mode"><pre class="language-xml"><code><span class="token prolog">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>project</span> <span class="token attr-name">xmlns</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://maven.apache.org/POM/4.0.0<span class="token punctuation">&quot;</span></span>
         <span class="token attr-name"><span class="token namespace">xmlns:</span>xsi</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://www.w3.org/2001/XMLSchema-instance<span class="token punctuation">&quot;</span></span>
         <span class="token attr-name"><span class="token namespace">xsi:</span>schemaLocation</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>parent</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>service-client<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>com.stt.yygh<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>1.0<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>parent</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>modelVersion</span><span class="token punctuation">&gt;</span></span>4.0.0<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>modelVersion</span><span class="token punctuation">&gt;</span></span>

    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>service-hosp-client<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>packaging</span><span class="token punctuation">&gt;</span></span>jar<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>packaging</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>1.0<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>name</span><span class="token punctuation">&gt;</span></span>service-hosp-client<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>name</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>description</span><span class="token punctuation">&gt;</span></span>service-hosp-client<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>description</span><span class="token punctuation">&gt;</span></span>

    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>properties</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>maven.compiler.source</span><span class="token punctuation">&gt;</span></span>8<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>maven.compiler.source</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>maven.compiler.target</span><span class="token punctuation">&gt;</span></span>8<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>maven.compiler.target</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>properties</span><span class="token punctuation">&gt;</span></span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>project</span><span class="token punctuation">&gt;</span></span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br></div></div><h4 id="添加feign接口类-2"><a href="#添加feign接口类-2" class="header-anchor">#</a> 添加feign接口类</h4> <p>创建 <code>com.stt.yygh.hosp.client.HospitalFeignClient</code> 类，并添加如下path</p> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>hosp<span class="token punctuation">.</span>client</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>vo<span class="token punctuation">.</span>hosp<span class="token punctuation">.</span></span><span class="token class-name">ScheduleOrderVo</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>vo<span class="token punctuation">.</span>hosp<span class="token punctuation">.</span></span><span class="token class-name">SignInfoVo</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>cloud<span class="token punctuation">.</span>openfeign<span class="token punctuation">.</span></span><span class="token class-name">FeignClient</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>stereotype<span class="token punctuation">.</span></span><span class="token class-name">Component</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>web<span class="token punctuation">.</span>bind<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span></span><span class="token class-name">GetMapping</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>web<span class="token punctuation">.</span>bind<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span></span><span class="token class-name">PathVariable</span><span class="token punctuation">;</span>

<span class="token annotation punctuation">@FeignClient</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;service-hosp&quot;</span><span class="token punctuation">)</span>
<span class="token annotation punctuation">@Component</span>
<span class="token keyword">public</span> <span class="token keyword">interface</span> <span class="token class-name">HospitalFeignClient</span> <span class="token punctuation">{</span>
    
    <span class="token comment">/**
     * 根据排班id获取预约下单数据
     */</span>
    <span class="token annotation punctuation">@GetMapping</span><span class="token punctuation">(</span><span class="token string">&quot;/api/hosp/hospital/inner/getScheduleOrderVo/{scheduleId}&quot;</span><span class="token punctuation">)</span>
    <span class="token class-name">ScheduleOrderVo</span> <span class="token function">getScheduleOrderVo</span><span class="token punctuation">(</span><span class="token annotation punctuation">@PathVariable</span><span class="token punctuation">(</span><span class="token string">&quot;scheduleId&quot;</span><span class="token punctuation">)</span> <span class="token class-name">String</span> scheduleId<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token comment">/**
     * 获取医院签名信息
     */</span>
    <span class="token annotation punctuation">@GetMapping</span><span class="token punctuation">(</span><span class="token string">&quot;/api/hosp/hospital/inner/getSignInfoVo/{hoscode}&quot;</span><span class="token punctuation">)</span>
    <span class="token class-name">SignInfoVo</span> <span class="token function">getSignInfoVo</span><span class="token punctuation">(</span><span class="token annotation punctuation">@PathVariable</span><span class="token punctuation">(</span><span class="token string">&quot;hoscode&quot;</span><span class="token punctuation">)</span> <span class="token class-name">String</span> hoscode<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br></div></div><h2 id="实现下单接口-service-order"><a href="#实现下单接口-service-order" class="header-anchor">#</a> 实现下单接口 service-order</h2> <h3 id="添加feign模块依赖"><a href="#添加feign模块依赖" class="header-anchor">#</a> 添加feign模块依赖</h3> <p>修改<code>service-order</code>模块的pom文件，添加如下依赖</p> <div class="language-xml line-numbers-mode"><pre class="language-xml"><code>    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependencies</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>com.stt.yygh<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>service-cmn-client<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>1.0<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>com.stt.yygh<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>service-user-client<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>1.0<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>com.stt.yygh<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>service-hosp-client<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>1.0<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependencies</span><span class="token punctuation">&gt;</span></span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br></div></div><h3 id="封装下单工具类"><a href="#封装下单工具类" class="header-anchor">#</a> 封装下单工具类</h3> <p>在common-util中添加如下工具类，如果之前已经添加可以忽略，该工具类用于给医院模拟系统发送http请求以及signKey的部分操作</p> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>common<span class="token punctuation">.</span>helper</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>fastjson<span class="token punctuation">.</span></span><span class="token class-name">JSONObject</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>common<span class="token punctuation">.</span>utils<span class="token punctuation">.</span></span><span class="token class-name">HttpUtil</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>common<span class="token punctuation">.</span>utils<span class="token punctuation">.</span></span>MD5<span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">lombok<span class="token punctuation">.</span>extern<span class="token punctuation">.</span>slf4j<span class="token punctuation">.</span></span><span class="token class-name">Slf4j</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">Date</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">HashMap</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">Map</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">TreeMap</span><span class="token punctuation">;</span>

<span class="token annotation punctuation">@Slf4j</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">HttpRequestHelper</span> <span class="token punctuation">{</span>

    <span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token class-name">Map</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span> <span class="token class-name">Object</span><span class="token punctuation">&gt;</span></span> <span class="token function">switchMap</span><span class="token punctuation">(</span><span class="token class-name">Map</span><span class="token operator">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span> <span class="token class-name">String</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token operator">&gt;</span> paramMap<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token class-name">Map</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span> <span class="token class-name">Object</span><span class="token punctuation">&gt;</span></span> resultMap <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">HashMap</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token class-name">Map<span class="token punctuation">.</span>Entry</span><span class="token operator">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span> <span class="token class-name">String</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token operator">&gt;</span> param <span class="token operator">:</span> paramMap<span class="token punctuation">.</span><span class="token function">entrySet</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            resultMap<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span>param<span class="token punctuation">.</span><span class="token function">getKey</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> param<span class="token punctuation">.</span><span class="token function">getValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token keyword">return</span> resultMap<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token comment">/**
     * 请求数据获取签名
     *
     * @param paramMap
     * @param signKey
     * @return
     */</span>
    <span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token class-name">String</span> <span class="token function">getSign</span><span class="token punctuation">(</span><span class="token class-name">Map</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span> <span class="token class-name">Object</span><span class="token punctuation">&gt;</span></span> paramMap<span class="token punctuation">,</span> <span class="token class-name">String</span> signKey<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>paramMap<span class="token punctuation">.</span><span class="token function">containsKey</span><span class="token punctuation">(</span><span class="token string">&quot;sign&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            paramMap<span class="token punctuation">.</span><span class="token function">remove</span><span class="token punctuation">(</span><span class="token string">&quot;sign&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token class-name">TreeMap</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span> <span class="token class-name">Object</span><span class="token punctuation">&gt;</span></span> sorted <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">TreeMap</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span>paramMap<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">StringBuilder</span> str <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">StringBuilder</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token class-name">Map<span class="token punctuation">.</span>Entry</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span> <span class="token class-name">Object</span><span class="token punctuation">&gt;</span></span> param <span class="token operator">:</span> sorted<span class="token punctuation">.</span><span class="token function">entrySet</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            str<span class="token punctuation">.</span><span class="token function">append</span><span class="token punctuation">(</span>param<span class="token punctuation">.</span><span class="token function">getValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">append</span><span class="token punctuation">(</span><span class="token string">&quot;|&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        str<span class="token punctuation">.</span><span class="token function">append</span><span class="token punctuation">(</span>signKey<span class="token punctuation">)</span><span class="token punctuation">;</span>
        log<span class="token punctuation">.</span><span class="token function">info</span><span class="token punctuation">(</span><span class="token string">&quot;加密前：&quot;</span> <span class="token operator">+</span> str<span class="token punctuation">.</span><span class="token function">toString</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">String</span> md5Str <span class="token operator">=</span> MD5<span class="token punctuation">.</span><span class="token function">encrypt</span><span class="token punctuation">(</span>str<span class="token punctuation">.</span><span class="token function">toString</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        log<span class="token punctuation">.</span><span class="token function">info</span><span class="token punctuation">(</span><span class="token string">&quot;加密后：&quot;</span> <span class="token operator">+</span> md5Str<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">return</span> md5Str<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token comment">/**
     * 签名校验
     *
     * @param paramMap
     * @param signKey
     * @return
     */</span>
    <span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">boolean</span> <span class="token function">isSignEquals</span><span class="token punctuation">(</span><span class="token class-name">Map</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span> <span class="token class-name">Object</span><span class="token punctuation">&gt;</span></span> paramMap<span class="token punctuation">,</span> <span class="token class-name">String</span> signKey<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token class-name">String</span> sign <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token class-name">String</span><span class="token punctuation">)</span> paramMap<span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span><span class="token string">&quot;sign&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">String</span> md5Str <span class="token operator">=</span> <span class="token function">getSign</span><span class="token punctuation">(</span>paramMap<span class="token punctuation">,</span> signKey<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span>sign<span class="token punctuation">.</span><span class="token function">equals</span><span class="token punctuation">(</span>md5Str<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token keyword">return</span> <span class="token boolean">false</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token keyword">return</span> <span class="token boolean">true</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token comment">/**
     * 获取时间戳
     *
     * @return
     */</span>
    <span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">long</span> <span class="token function">getTimestamp</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> <span class="token keyword">new</span> <span class="token class-name">Date</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">getTime</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token comment">/**
     * 封装同步请求
     *
     * @param paramMap
     * @param url
     * @return
     */</span>
    <span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token class-name">JSONObject</span> <span class="token function">sendRequest</span><span class="token punctuation">(</span><span class="token class-name">Map</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span> <span class="token class-name">Object</span><span class="token punctuation">&gt;</span></span> paramMap<span class="token punctuation">,</span> <span class="token class-name">String</span> url<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token class-name">String</span> result <span class="token operator">=</span> <span class="token string">&quot;&quot;</span><span class="token punctuation">;</span>
        <span class="token keyword">try</span> <span class="token punctuation">{</span>
            <span class="token comment">//封装post参数</span>
            <span class="token class-name">StringBuilder</span> postdata <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">StringBuilder</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token class-name">Map<span class="token punctuation">.</span>Entry</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span> <span class="token class-name">Object</span><span class="token punctuation">&gt;</span></span> param <span class="token operator">:</span> paramMap<span class="token punctuation">.</span><span class="token function">entrySet</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
                postdata<span class="token punctuation">.</span><span class="token function">append</span><span class="token punctuation">(</span>param<span class="token punctuation">.</span><span class="token function">getKey</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">append</span><span class="token punctuation">(</span><span class="token string">&quot;=&quot;</span><span class="token punctuation">)</span>
                        <span class="token punctuation">.</span><span class="token function">append</span><span class="token punctuation">(</span>param<span class="token punctuation">.</span><span class="token function">getValue</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">append</span><span class="token punctuation">(</span><span class="token string">&quot;&amp;&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">}</span>
            log<span class="token punctuation">.</span><span class="token function">info</span><span class="token punctuation">(</span><span class="token class-name">String</span><span class="token punctuation">.</span><span class="token function">format</span><span class="token punctuation">(</span><span class="token string">&quot;--&gt; 发送请求：post data %1s&quot;</span><span class="token punctuation">,</span> postdata<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">byte</span><span class="token punctuation">[</span><span class="token punctuation">]</span> reqData <span class="token operator">=</span> postdata<span class="token punctuation">.</span><span class="token function">toString</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">getBytes</span><span class="token punctuation">(</span><span class="token string">&quot;utf-8&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">byte</span><span class="token punctuation">[</span><span class="token punctuation">]</span> respdata <span class="token operator">=</span> <span class="token class-name">HttpUtil</span><span class="token punctuation">.</span><span class="token function">doPost</span><span class="token punctuation">(</span>url<span class="token punctuation">,</span> reqData<span class="token punctuation">)</span><span class="token punctuation">;</span>
            result <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">String</span><span class="token punctuation">(</span>respdata<span class="token punctuation">)</span><span class="token punctuation">;</span>
            log<span class="token punctuation">.</span><span class="token function">info</span><span class="token punctuation">(</span><span class="token class-name">String</span><span class="token punctuation">.</span><span class="token function">format</span><span class="token punctuation">(</span><span class="token string">&quot;--&gt; 应答结果：result data %1s&quot;</span><span class="token punctuation">,</span> result<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span> <span class="token keyword">catch</span> <span class="token punctuation">(</span><span class="token class-name">Exception</span> ex<span class="token punctuation">)</span> <span class="token punctuation">{</span>
            ex<span class="token punctuation">.</span><span class="token function">printStackTrace</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token keyword">return</span> <span class="token class-name">JSONObject</span><span class="token punctuation">.</span><span class="token function">parseObject</span><span class="token punctuation">(</span>result<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br><span class="line-number">41</span><br><span class="line-number">42</span><br><span class="line-number">43</span><br><span class="line-number">44</span><br><span class="line-number">45</span><br><span class="line-number">46</span><br><span class="line-number">47</span><br><span class="line-number">48</span><br><span class="line-number">49</span><br><span class="line-number">50</span><br><span class="line-number">51</span><br><span class="line-number">52</span><br><span class="line-number">53</span><br><span class="line-number">54</span><br><span class="line-number">55</span><br><span class="line-number">56</span><br><span class="line-number">57</span><br><span class="line-number">58</span><br><span class="line-number">59</span><br><span class="line-number">60</span><br><span class="line-number">61</span><br><span class="line-number">62</span><br><span class="line-number">63</span><br><span class="line-number">64</span><br><span class="line-number">65</span><br><span class="line-number">66</span><br><span class="line-number">67</span><br><span class="line-number">68</span><br><span class="line-number">69</span><br><span class="line-number">70</span><br><span class="line-number">71</span><br><span class="line-number">72</span><br><span class="line-number">73</span><br><span class="line-number">74</span><br><span class="line-number">75</span><br><span class="line-number">76</span><br><span class="line-number">77</span><br><span class="line-number">78</span><br><span class="line-number">79</span><br><span class="line-number">80</span><br><span class="line-number">81</span><br><span class="line-number">82</span><br><span class="line-number">83</span><br><span class="line-number">84</span><br><span class="line-number">85</span><br><span class="line-number">86</span><br><span class="line-number">87</span><br><span class="line-number">88</span><br><span class="line-number">89</span><br><span class="line-number">90</span><br><span class="line-number">91</span><br><span class="line-number">92</span><br><span class="line-number">93</span><br><span class="line-number">94</span><br><span class="line-number">95</span><br><span class="line-number">96</span><br><span class="line-number">97</span><br><span class="line-number">98</span><br></div></div><h3 id="实现保存订单方法"><a href="#实现保存订单方法" class="header-anchor">#</a> 实现保存订单方法</h3> <p>通过feign调用就诊人信息，调用排班信息，生成订单信息，发送给远端医院模拟系统，返回订单信息并更新，最后发送一个异步mq消息更新排班和可预约数目，以及发送短信通知就诊人</p> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>order<span class="token punctuation">.</span>service<span class="token punctuation">.</span>impl</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>fastjson<span class="token punctuation">.</span></span><span class="token class-name">JSONObject</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>baomidou<span class="token punctuation">.</span>mybatisplus<span class="token punctuation">.</span>extension<span class="token punctuation">.</span>service<span class="token punctuation">.</span>impl<span class="token punctuation">.</span></span><span class="token class-name">ServiceImpl</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>common<span class="token punctuation">.</span>exception<span class="token punctuation">.</span></span><span class="token class-name">YyghException</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>common<span class="token punctuation">.</span>helper<span class="token punctuation">.</span></span><span class="token class-name">HttpRequestHelper</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>common<span class="token punctuation">.</span>result<span class="token punctuation">.</span></span><span class="token class-name">ResultCodeEnum</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>enums<span class="token punctuation">.</span></span><span class="token class-name">OrderStatusEnum</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>hosp<span class="token punctuation">.</span>client<span class="token punctuation">.</span></span><span class="token class-name">HospitalFeignClient</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>model<span class="token punctuation">.</span>order<span class="token punctuation">.</span></span><span class="token class-name">OrderInfo</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>model<span class="token punctuation">.</span>user<span class="token punctuation">.</span></span><span class="token class-name">Patient</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>order<span class="token punctuation">.</span>mapper<span class="token punctuation">.</span></span><span class="token class-name">OrderInfoMapper</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>order<span class="token punctuation">.</span>service<span class="token punctuation">.</span></span><span class="token class-name">OrderService</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>user<span class="token punctuation">.</span>client<span class="token punctuation">.</span></span><span class="token class-name">PatientFeignClient</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>vo<span class="token punctuation">.</span>hosp<span class="token punctuation">.</span></span><span class="token class-name">ScheduleOrderVo</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>vo<span class="token punctuation">.</span>hosp<span class="token punctuation">.</span></span><span class="token class-name">SignInfoVo</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>joda<span class="token punctuation">.</span>time<span class="token punctuation">.</span></span><span class="token class-name">DateTime</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>beans<span class="token punctuation">.</span></span><span class="token class-name">BeanUtils</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>beans<span class="token punctuation">.</span>factory<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span></span><span class="token class-name">Autowired</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>stereotype<span class="token punctuation">.</span></span><span class="token class-name">Service</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">HashMap</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">Map</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">Objects</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">Random</span><span class="token punctuation">;</span>

<span class="token annotation punctuation">@Service</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">OrderServiceImpl</span> <span class="token keyword">extends</span> <span class="token class-name">ServiceImpl</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">OrderInfoMapper</span><span class="token punctuation">,</span> <span class="token class-name">OrderInfo</span><span class="token punctuation">&gt;</span></span> <span class="token keyword">implements</span> <span class="token class-name">OrderService</span> <span class="token punctuation">{</span>

    <span class="token annotation punctuation">@Autowired</span>
    <span class="token keyword">private</span> <span class="token class-name">PatientFeignClient</span> patientFeignClient<span class="token punctuation">;</span>

    <span class="token annotation punctuation">@Autowired</span>
    <span class="token keyword">private</span> <span class="token class-name">HospitalFeignClient</span> hospitalFeignClient<span class="token punctuation">;</span>

    <span class="token comment">//保存订单</span>
    <span class="token annotation punctuation">@Override</span>
    <span class="token keyword">public</span> <span class="token class-name">Long</span> <span class="token function">saveOrder</span><span class="token punctuation">(</span><span class="token class-name">String</span> scheduleId<span class="token punctuation">,</span> <span class="token class-name">Long</span> patientId<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token class-name">Patient</span> patient <span class="token operator">=</span> patientFeignClient<span class="token punctuation">.</span><span class="token function">getPatientInfo</span><span class="token punctuation">(</span>patientId<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token class-name">Objects</span><span class="token punctuation">.</span><span class="token function">isNull</span><span class="token punctuation">(</span>patient<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token keyword">throw</span> <span class="token keyword">new</span> <span class="token class-name">YyghException</span><span class="token punctuation">(</span><span class="token class-name">ResultCodeEnum</span><span class="token punctuation">.</span>DATA_ERROR<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token class-name">OrderInfo</span> order <span class="token operator">=</span> <span class="token function">createAndSaveOrder</span><span class="token punctuation">(</span>scheduleId<span class="token punctuation">,</span> patient<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">JSONObject</span> resp <span class="token operator">=</span> <span class="token function">accessRemoteHospAndCreateOrder</span><span class="token punctuation">(</span>order<span class="token punctuation">,</span> patient<span class="token punctuation">)</span><span class="token punctuation">;</span>
        order<span class="token punctuation">.</span><span class="token function">setHosRecordId</span><span class="token punctuation">(</span>resp<span class="token punctuation">.</span><span class="token function">getString</span><span class="token punctuation">(</span><span class="token string">&quot;hosRecordId&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>    <span class="token comment">//预约记录唯一标识（医院预约记录主键）</span>
        order<span class="token punctuation">.</span><span class="token function">setNumber</span><span class="token punctuation">(</span>resp<span class="token punctuation">.</span><span class="token function">getInteger</span><span class="token punctuation">(</span><span class="token string">&quot;number&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>             <span class="token comment">//预约序号</span>
        order<span class="token punctuation">.</span><span class="token function">setFetchTime</span><span class="token punctuation">(</span>resp<span class="token punctuation">.</span><span class="token function">getString</span><span class="token punctuation">(</span><span class="token string">&quot;fetchTime&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>        <span class="token comment">//取号时间</span>
        order<span class="token punctuation">.</span><span class="token function">setFetchAddress</span><span class="token punctuation">(</span>resp<span class="token punctuation">.</span><span class="token function">getString</span><span class="token punctuation">(</span><span class="token string">&quot;fetchAddress&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  <span class="token comment">//取号地址</span>
        baseMapper<span class="token punctuation">.</span><span class="token function">updateById</span><span class="token punctuation">(</span>order<span class="token punctuation">)</span><span class="token punctuation">;</span>                               <span class="token comment">//更新订单</span>

        <span class="token comment">//排班可预约数</span>
        <span class="token class-name">Integer</span> reservedNumber <span class="token operator">=</span> resp<span class="token punctuation">.</span><span class="token function">getInteger</span><span class="token punctuation">(</span><span class="token string">&quot;reservedNumber&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//排班剩余预约数</span>
        <span class="token class-name">Integer</span> availableNumber <span class="token operator">=</span> resp<span class="token punctuation">.</span><span class="token function">getInteger</span><span class="token punctuation">(</span><span class="token string">&quot;availableNumber&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// todo 发送mq信息更新号源和短信通知</span>
        
        <span class="token keyword">return</span> order<span class="token punctuation">.</span><span class="token function">getId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    
    <span class="token comment">// 访问远端医院模拟系统，并创建订单，返回对应的参数并存储</span>
    <span class="token keyword">private</span> <span class="token class-name">JSONObject</span> <span class="token function">accessRemoteHospAndCreateOrder</span><span class="token punctuation">(</span><span class="token class-name">OrderInfo</span> order<span class="token punctuation">,</span> <span class="token class-name">Patient</span> patient<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token class-name">SignInfoVo</span> signInfo <span class="token operator">=</span> hospitalFeignClient<span class="token punctuation">.</span><span class="token function">getSignInfoVo</span><span class="token punctuation">(</span>order<span class="token punctuation">.</span><span class="token function">getHoscode</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token class-name">Objects</span><span class="token punctuation">.</span><span class="token function">isNull</span><span class="token punctuation">(</span>signInfo<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token keyword">throw</span> <span class="token keyword">new</span> <span class="token class-name">YyghException</span><span class="token punctuation">(</span><span class="token class-name">ResultCodeEnum</span><span class="token punctuation">.</span>DATA_ERROR<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token class-name">Map</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span> <span class="token class-name">Object</span><span class="token punctuation">&gt;</span></span> param <span class="token operator">=</span> <span class="token function">createHospParam</span><span class="token punctuation">(</span>order<span class="token punctuation">,</span> patient<span class="token punctuation">,</span> signInfo<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">JSONObject</span> re <span class="token operator">=</span> <span class="token class-name">HttpRequestHelper</span><span class="token punctuation">.</span><span class="token function">sendRequest</span><span class="token punctuation">(</span>param<span class="token punctuation">,</span> signInfo<span class="token punctuation">.</span><span class="token function">getApiUrl</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">&quot;/order/submitOrder&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>re<span class="token punctuation">.</span><span class="token function">getInteger</span><span class="token punctuation">(</span><span class="token string">&quot;code&quot;</span><span class="token punctuation">)</span> <span class="token operator">!=</span> <span class="token number">200</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token keyword">throw</span> <span class="token keyword">new</span> <span class="token class-name">YyghException</span><span class="token punctuation">(</span>re<span class="token punctuation">.</span><span class="token function">getString</span><span class="token punctuation">(</span><span class="token string">&quot;message&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token class-name">ResultCodeEnum</span><span class="token punctuation">.</span>FAIL<span class="token punctuation">.</span><span class="token function">getCode</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token keyword">return</span> re<span class="token punctuation">.</span><span class="token function">getJSONObject</span><span class="token punctuation">(</span><span class="token string">&quot;data&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token keyword">private</span> <span class="token class-name">OrderInfo</span> <span class="token function">createAndSaveOrder</span><span class="token punctuation">(</span><span class="token class-name">String</span> scheduleId<span class="token punctuation">,</span> <span class="token class-name">Patient</span> patient<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token class-name">ScheduleOrderVo</span> scheduleOrder <span class="token operator">=</span> hospitalFeignClient<span class="token punctuation">.</span><span class="token function">getScheduleOrderVo</span><span class="token punctuation">(</span>scheduleId<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token class-name">Objects</span><span class="token punctuation">.</span><span class="token function">isNull</span><span class="token punctuation">(</span>scheduleOrder<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token keyword">throw</span> <span class="token keyword">new</span> <span class="token class-name">YyghException</span><span class="token punctuation">(</span><span class="token class-name">ResultCodeEnum</span><span class="token punctuation">.</span>DATA_ERROR<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token comment">//当前时间不可以预约</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">DateTime</span><span class="token punctuation">(</span>scheduleOrder<span class="token punctuation">.</span><span class="token function">getStartTime</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">isAfterNow</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">||</span> <span class="token keyword">new</span> <span class="token class-name">DateTime</span><span class="token punctuation">(</span>scheduleOrder<span class="token punctuation">.</span><span class="token function">getEndTime</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">isBeforeNow</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token keyword">throw</span> <span class="token keyword">new</span> <span class="token class-name">YyghException</span><span class="token punctuation">(</span><span class="token class-name">ResultCodeEnum</span><span class="token punctuation">.</span>TIME_NO<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span>scheduleOrder<span class="token punctuation">.</span><span class="token function">getAvailableNumber</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">&lt;=</span> <span class="token number">0</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token keyword">throw</span> <span class="token keyword">new</span> <span class="token class-name">YyghException</span><span class="token punctuation">(</span><span class="token class-name">ResultCodeEnum</span><span class="token punctuation">.</span>NUMBER_NO<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token class-name">OrderInfo</span> re <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">OrderInfo</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">BeanUtils</span><span class="token punctuation">.</span><span class="token function">copyProperties</span><span class="token punctuation">(</span>scheduleOrder<span class="token punctuation">,</span> re<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 注意：这里是hosScheduleId字段，需要包含医院的模拟id 以及 mongodb 预约记录的id 合并在一起</span>
        re<span class="token punctuation">.</span><span class="token function">setScheduleId</span><span class="token punctuation">(</span>scheduleOrder<span class="token punctuation">.</span><span class="token function">getHosScheduleId</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">&quot;@&quot;</span> <span class="token operator">+</span> scheduleId<span class="token punctuation">)</span><span class="token punctuation">;</span>
        re<span class="token punctuation">.</span><span class="token function">setOutTradeNo</span><span class="token punctuation">(</span><span class="token class-name">System</span><span class="token punctuation">.</span><span class="token function">currentTimeMillis</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">&quot;&quot;</span> <span class="token operator">+</span> <span class="token keyword">new</span> <span class="token class-name">Random</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">nextInt</span><span class="token punctuation">(</span><span class="token number">100</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        re<span class="token punctuation">.</span><span class="token function">setUserId</span><span class="token punctuation">(</span>patient<span class="token punctuation">.</span><span class="token function">getUserId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        re<span class="token punctuation">.</span><span class="token function">setPatientId</span><span class="token punctuation">(</span>patient<span class="token punctuation">.</span><span class="token function">getId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        re<span class="token punctuation">.</span><span class="token function">setPatientName</span><span class="token punctuation">(</span>patient<span class="token punctuation">.</span><span class="token function">getName</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        re<span class="token punctuation">.</span><span class="token function">setPatientPhone</span><span class="token punctuation">(</span>patient<span class="token punctuation">.</span><span class="token function">getPhone</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        re<span class="token punctuation">.</span><span class="token function">setOrderStatus</span><span class="token punctuation">(</span><span class="token class-name">OrderStatusEnum</span><span class="token punctuation">.</span>UNPAID<span class="token punctuation">.</span><span class="token function">getStatus</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">save</span><span class="token punctuation">(</span>re<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">return</span> re<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token comment">// 调用医院模拟系统接口时传递的参数</span>
    <span class="token keyword">private</span> <span class="token class-name">Map</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span> <span class="token class-name">Object</span><span class="token punctuation">&gt;</span></span> <span class="token function">createHospParam</span><span class="token punctuation">(</span><span class="token class-name">OrderInfo</span> order<span class="token punctuation">,</span> <span class="token class-name">Patient</span> patient<span class="token punctuation">,</span> <span class="token class-name">SignInfoVo</span> signInfo<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token class-name">Map</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span> <span class="token class-name">Object</span><span class="token punctuation">&gt;</span></span> re <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">HashMap</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        re<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">&quot;hoscode&quot;</span><span class="token punctuation">,</span> order<span class="token punctuation">.</span><span class="token function">getHoscode</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        re<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">&quot;depcode&quot;</span><span class="token punctuation">,</span> order<span class="token punctuation">.</span><span class="token function">getDepcode</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        re<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">&quot;hosScheduleId&quot;</span><span class="token punctuation">,</span> order<span class="token punctuation">.</span><span class="token function">getScheduleId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">split</span><span class="token punctuation">(</span><span class="token string">&quot;@&quot;</span><span class="token punctuation">)</span><span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        re<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">&quot;reserveDate&quot;</span><span class="token punctuation">,</span> <span class="token keyword">new</span> <span class="token class-name">DateTime</span><span class="token punctuation">(</span>order<span class="token punctuation">.</span><span class="token function">getReserveDate</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">toString</span><span class="token punctuation">(</span><span class="token string">&quot;yyyy-MM-dd&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        re<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">&quot;reserveTime&quot;</span><span class="token punctuation">,</span> order<span class="token punctuation">.</span><span class="token function">getReserveTime</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        re<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">&quot;amount&quot;</span><span class="token punctuation">,</span> order<span class="token punctuation">.</span><span class="token function">getAmount</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        re<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">&quot;name&quot;</span><span class="token punctuation">,</span> order<span class="token punctuation">.</span><span class="token function">getPatientName</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        re<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">&quot;certificatesType&quot;</span><span class="token punctuation">,</span> patient<span class="token punctuation">.</span><span class="token function">getCertificatesType</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        re<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">&quot;certificatesNo&quot;</span><span class="token punctuation">,</span> patient<span class="token punctuation">.</span><span class="token function">getCertificatesNo</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        re<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">&quot;sex&quot;</span><span class="token punctuation">,</span> patient<span class="token punctuation">.</span><span class="token function">getSex</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        re<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">&quot;birthdate&quot;</span><span class="token punctuation">,</span> patient<span class="token punctuation">.</span><span class="token function">getBirthdate</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        re<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">&quot;phone&quot;</span><span class="token punctuation">,</span> patient<span class="token punctuation">.</span><span class="token function">getPhone</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        re<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">&quot;isMarry&quot;</span><span class="token punctuation">,</span> patient<span class="token punctuation">.</span><span class="token function">getIsMarry</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        re<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">&quot;provinceCode&quot;</span><span class="token punctuation">,</span> patient<span class="token punctuation">.</span><span class="token function">getProvinceCode</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        re<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">&quot;cityCode&quot;</span><span class="token punctuation">,</span> patient<span class="token punctuation">.</span><span class="token function">getCityCode</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        re<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">&quot;districtCode&quot;</span><span class="token punctuation">,</span> patient<span class="token punctuation">.</span><span class="token function">getDistrictCode</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        re<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">&quot;address&quot;</span><span class="token punctuation">,</span> patient<span class="token punctuation">.</span><span class="token function">getAddress</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//联系人</span>
        re<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">&quot;contactsName&quot;</span><span class="token punctuation">,</span> patient<span class="token punctuation">.</span><span class="token function">getContactsName</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        re<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">&quot;contactsCertificatesType&quot;</span><span class="token punctuation">,</span> patient<span class="token punctuation">.</span><span class="token function">getContactsCertificatesType</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        re<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">&quot;contactsCertificatesNo&quot;</span><span class="token punctuation">,</span> patient<span class="token punctuation">.</span><span class="token function">getContactsCertificatesNo</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        re<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">&quot;contactsPhone&quot;</span><span class="token punctuation">,</span> patient<span class="token punctuation">.</span><span class="token function">getContactsPhone</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        re<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">&quot;timestamp&quot;</span><span class="token punctuation">,</span> <span class="token class-name">HttpRequestHelper</span><span class="token punctuation">.</span><span class="token function">getTimestamp</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        re<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">&quot;sign&quot;</span><span class="token punctuation">,</span> <span class="token class-name">HttpRequestHelper</span><span class="token punctuation">.</span><span class="token function">getSign</span><span class="token punctuation">(</span>re<span class="token punctuation">,</span> signInfo<span class="token punctuation">.</span><span class="token function">getSignKey</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">return</span> re<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br><span class="line-number">41</span><br><span class="line-number">42</span><br><span class="line-number">43</span><br><span class="line-number">44</span><br><span class="line-number">45</span><br><span class="line-number">46</span><br><span class="line-number">47</span><br><span class="line-number">48</span><br><span class="line-number">49</span><br><span class="line-number">50</span><br><span class="line-number">51</span><br><span class="line-number">52</span><br><span class="line-number">53</span><br><span class="line-number">54</span><br><span class="line-number">55</span><br><span class="line-number">56</span><br><span class="line-number">57</span><br><span class="line-number">58</span><br><span class="line-number">59</span><br><span class="line-number">60</span><br><span class="line-number">61</span><br><span class="line-number">62</span><br><span class="line-number">63</span><br><span class="line-number">64</span><br><span class="line-number">65</span><br><span class="line-number">66</span><br><span class="line-number">67</span><br><span class="line-number">68</span><br><span class="line-number">69</span><br><span class="line-number">70</span><br><span class="line-number">71</span><br><span class="line-number">72</span><br><span class="line-number">73</span><br><span class="line-number">74</span><br><span class="line-number">75</span><br><span class="line-number">76</span><br><span class="line-number">77</span><br><span class="line-number">78</span><br><span class="line-number">79</span><br><span class="line-number">80</span><br><span class="line-number">81</span><br><span class="line-number">82</span><br><span class="line-number">83</span><br><span class="line-number">84</span><br><span class="line-number">85</span><br><span class="line-number">86</span><br><span class="line-number">87</span><br><span class="line-number">88</span><br><span class="line-number">89</span><br><span class="line-number">90</span><br><span class="line-number">91</span><br><span class="line-number">92</span><br><span class="line-number">93</span><br><span class="line-number">94</span><br><span class="line-number">95</span><br><span class="line-number">96</span><br><span class="line-number">97</span><br><span class="line-number">98</span><br><span class="line-number">99</span><br><span class="line-number">100</span><br><span class="line-number">101</span><br><span class="line-number">102</span><br><span class="line-number">103</span><br><span class="line-number">104</span><br><span class="line-number">105</span><br><span class="line-number">106</span><br><span class="line-number">107</span><br><span class="line-number">108</span><br><span class="line-number">109</span><br><span class="line-number">110</span><br><span class="line-number">111</span><br><span class="line-number">112</span><br><span class="line-number">113</span><br><span class="line-number">114</span><br><span class="line-number">115</span><br><span class="line-number">116</span><br><span class="line-number">117</span><br><span class="line-number">118</span><br><span class="line-number">119</span><br><span class="line-number">120</span><br><span class="line-number">121</span><br><span class="line-number">122</span><br><span class="line-number">123</span><br><span class="line-number">124</span><br><span class="line-number">125</span><br><span class="line-number">126</span><br><span class="line-number">127</span><br><span class="line-number">128</span><br><span class="line-number">129</span><br></div></div><h2 id="预约成功后处理"><a href="#预约成功后处理" class="header-anchor">#</a> 预约成功后处理</h2> <p>预约成功后要更新预约数和短信提醒预约成功，为了提高下单的并发性，这部分逻辑交给mq为我们完成，预约成功发送消息即可</p> <div class="custom-block tip"><p class="custom-block-title">提示</p> <p>使用RabbitMQ作为消息中间件，注意当前使用版本 3.9.11</p></div> <div class="cardListContainer"><div class="card-list"><a href="/pages/b0911c/" target="_blank" class="card-item row-1" style="background-color:#DFEEE7;--random-color:#DFEEE7;color:#2A3344;"><div><p class="name">快速访问 🚀 RabbitMQ</p> <p class="desc">使用RabbitMQ作为消息中间件</p></div></a></div><div class="language-yaml line-numbers-mode"><pre class="language-yaml"><code><span class="token punctuation">-</span> <span class="token key atrule">name</span><span class="token punctuation">:</span> 快速访问 🚀 RabbitMQ 
  <span class="token key atrule">desc</span><span class="token punctuation">:</span> 使用RabbitMQ作为消息中间件
  <span class="token key atrule">link</span><span class="token punctuation">:</span> /pages/b0911c/
  <span class="token key atrule">bgColor</span><span class="token punctuation">:</span> <span class="token string">'#DFEEE7'</span>
  <span class="token key atrule">textColor</span><span class="token punctuation">:</span> <span class="token string">'#2A3344'</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div></div><h3 id="创建rabbitmq-util模块"><a href="#创建rabbitmq-util模块" class="header-anchor">#</a> 创建rabbitmq-util模块</h3> <p>由于后续可能多个模块都会使用mq，把它封装成一个模块，需要的地方直接引用即可</p> <p>在common模块下搭建，搭建过程如：common-util</p> <h4 id="修改pom-4"><a href="#修改pom-4" class="header-anchor">#</a> 修改pom</h4> <p>引入rabbitmq消息队列依赖</p> <div class="language-xml line-numbers-mode"><pre class="language-xml"><code><span class="token prolog">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>project</span> <span class="token attr-name">xmlns</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://maven.apache.org/POM/4.0.0<span class="token punctuation">&quot;</span></span>
         <span class="token attr-name"><span class="token namespace">xmlns:</span>xsi</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://www.w3.org/2001/XMLSchema-instance<span class="token punctuation">&quot;</span></span>
         <span class="token attr-name"><span class="token namespace">xsi:</span>schemaLocation</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>parent</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>common<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>com.stt.yygh<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>0.0.1<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>parent</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>modelVersion</span><span class="token punctuation">&gt;</span></span>4.0.0<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>modelVersion</span><span class="token punctuation">&gt;</span></span>

    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>rabbitmq-util<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>0.0.1<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>packaging</span><span class="token punctuation">&gt;</span></span>jar<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>packaging</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>name</span><span class="token punctuation">&gt;</span></span>rabbitmq-util<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>name</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>description</span><span class="token punctuation">&gt;</span></span>rabbitmq-util<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>description</span><span class="token punctuation">&gt;</span></span>

    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>properties</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>maven.compiler.source</span><span class="token punctuation">&gt;</span></span>8<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>maven.compiler.source</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>maven.compiler.target</span><span class="token punctuation">&gt;</span></span>8<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>maven.compiler.target</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>properties</span><span class="token punctuation">&gt;</span></span>

    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependencies</span><span class="token punctuation">&gt;</span></span>
        <span class="token comment">&lt;!--rabbitmq消息队列--&gt;</span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>org.springframework.boot<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>spring-boot-starter-actuator<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>org.springframework.cloud<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>spring-cloud-starter-bus-amqp<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>com.alibaba<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>fastjson<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependencies</span><span class="token punctuation">&gt;</span></span>
    
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>project</span><span class="token punctuation">&gt;</span></span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br></div></div><h4 id="封装service方法"><a href="#封装service方法" class="header-anchor">#</a> 封装service方法</h4> <p>创建<code>RabbitService</code> 类，添加发送消息的方法</p> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>rabbitmq</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>amqp<span class="token punctuation">.</span>rabbit<span class="token punctuation">.</span>core<span class="token punctuation">.</span></span><span class="token class-name">RabbitTemplate</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>beans<span class="token punctuation">.</span>factory<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span></span><span class="token class-name">Autowired</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>stereotype<span class="token punctuation">.</span></span><span class="token class-name">Service</span><span class="token punctuation">;</span>

<span class="token annotation punctuation">@Service</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">RabbitService</span> <span class="token punctuation">{</span>

    <span class="token annotation punctuation">@Autowired</span>
    <span class="token keyword">private</span> <span class="token class-name">RabbitTemplate</span> rabbitTemplate<span class="token punctuation">;</span>

    <span class="token comment">/**
     *  发送消息
     * @param exchange 交换机
     * @param routingKey 路由键
     * @param message 消息
     */</span>
    <span class="token keyword">public</span> <span class="token keyword">boolean</span> <span class="token function">sendMessage</span><span class="token punctuation">(</span><span class="token class-name">String</span> exchange<span class="token punctuation">,</span> <span class="token class-name">String</span> routingKey<span class="token punctuation">,</span> <span class="token class-name">Object</span> message<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        rabbitTemplate<span class="token punctuation">.</span><span class="token function">convertAndSend</span><span class="token punctuation">(</span>exchange<span class="token punctuation">,</span> routingKey<span class="token punctuation">,</span> message<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">return</span> <span class="token boolean">true</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br></div></div><h4 id="配置mq消息转换器"><a href="#配置mq消息转换器" class="header-anchor">#</a> 配置mq消息转换器</h4> <p>创建<code>MqConfig</code> 类并添加转换bean，将传递的消息转换为json</p> <ul><li>注：默认是字符串转换器</li></ul> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>rabbitmq</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>amqp<span class="token punctuation">.</span>support<span class="token punctuation">.</span>converter<span class="token punctuation">.</span></span><span class="token class-name">Jackson2JsonMessageConverter</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>amqp<span class="token punctuation">.</span>support<span class="token punctuation">.</span>converter<span class="token punctuation">.</span></span><span class="token class-name">MessageConverter</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>context<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span></span><span class="token class-name">Bean</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>context<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span></span><span class="token class-name">Configuration</span><span class="token punctuation">;</span>

<span class="token annotation punctuation">@Configuration</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">MqConfig</span> <span class="token punctuation">{</span>

    <span class="token annotation punctuation">@Bean</span>
    <span class="token keyword">public</span> <span class="token class-name">MessageConverter</span> <span class="token function">messageConverter</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> <span class="token keyword">new</span> <span class="token class-name">Jackson2JsonMessageConverter</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br></div></div><h4 id="添加常量配置"><a href="#添加常量配置" class="header-anchor">#</a> 添加常量配置</h4> <p>用于业务中发送消息使用的常量定义</p> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>rabbitmq</span><span class="token punctuation">;</span>

<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">MqConst</span> <span class="token punctuation">{</span>

    <span class="token comment">//预约下单</span>
    <span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">final</span> <span class="token class-name">String</span> EXCHANGE_DIRECT_ORDER <span class="token operator">=</span> <span class="token string">&quot;exchange.direct.order&quot;</span><span class="token punctuation">;</span>
    <span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">final</span> <span class="token class-name">String</span> ROUTING_ORDER <span class="token operator">=</span> <span class="token string">&quot;order&quot;</span><span class="token punctuation">;</span>

    <span class="token comment">//队列</span>
    <span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">final</span> <span class="token class-name">String</span> QUEUE_ORDER  <span class="token operator">=</span> <span class="token string">&quot;queue.order&quot;</span><span class="token punctuation">;</span>

    <span class="token comment">//短信</span>
    <span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">final</span> <span class="token class-name">String</span> EXCHANGE_DIRECT_MSM <span class="token operator">=</span> <span class="token string">&quot;exchange.direct.msm&quot;</span><span class="token punctuation">;</span>
    <span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">final</span> <span class="token class-name">String</span> ROUTING_MSM_ITEM <span class="token operator">=</span> <span class="token string">&quot;msm.item&quot;</span><span class="token punctuation">;</span>
    <span class="token comment">//短信队列</span>
    <span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">final</span> <span class="token class-name">String</span> QUEUE_MSM_ITEM  <span class="token operator">=</span> <span class="token string">&quot;queue.msm.item&quot;</span><span class="token punctuation">;</span>

    <span class="token comment">//定时任务</span>
    <span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">final</span> <span class="token class-name">String</span> EXCHANGE_DIRECT_TASK <span class="token operator">=</span> <span class="token string">&quot;exchange.direct.task&quot;</span><span class="token punctuation">;</span>
    <span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">final</span> <span class="token class-name">String</span> ROUTING_TASK_8 <span class="token operator">=</span> <span class="token string">&quot;task.8&quot;</span><span class="token punctuation">;</span>

    <span class="token comment">//队列</span>
    <span class="token keyword">public</span> <span class="token keyword">static</span> <span class="token keyword">final</span> <span class="token class-name">String</span> QUEUE_TASK_8 <span class="token operator">=</span> <span class="token string">&quot;queue.task.8&quot;</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br></div></div><h3 id="封装短信接口-service-msm"><a href="#封装短信接口-service-msm" class="header-anchor">#</a> 封装短信接口 service-msm</h3> <p>在<code>service-msm</code>中接受mq消息，并发送短信</p> <h4 id="修改pom添加依赖"><a href="#修改pom添加依赖" class="header-anchor">#</a> 修改pom添加依赖</h4> <div class="language-xml line-numbers-mode"><div class="highlight-lines"><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><div class="highlighted"> </div><div class="highlighted"> </div><div class="highlighted"> </div><div class="highlighted"> </div><div class="highlighted"> </div><br><br><br><br></div><pre class="language-xml"><code><span class="token prolog">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>project</span> <span class="token attr-name">xmlns</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://maven.apache.org/POM/4.0.0<span class="token punctuation">&quot;</span></span>
         <span class="token attr-name"><span class="token namespace">xmlns:</span>xsi</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://www.w3.org/2001/XMLSchema-instance<span class="token punctuation">&quot;</span></span>
         <span class="token attr-name"><span class="token namespace">xsi:</span>schemaLocation</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>parent</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>service<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>com.stt.yygh<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>0.0.1<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>parent</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>modelVersion</span><span class="token punctuation">&gt;</span></span>4.0.0<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>modelVersion</span><span class="token punctuation">&gt;</span></span>

    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>1.0<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>service-msm<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>packaging</span><span class="token punctuation">&gt;</span></span>jar<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>packaging</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>name</span><span class="token punctuation">&gt;</span></span>service-msm<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>name</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>description</span><span class="token punctuation">&gt;</span></span>service-msm<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>description</span><span class="token punctuation">&gt;</span></span>

    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>properties</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>maven.compiler.source</span><span class="token punctuation">&gt;</span></span>8<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>maven.compiler.source</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>maven.compiler.target</span><span class="token punctuation">&gt;</span></span>8<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>maven.compiler.target</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>properties</span><span class="token punctuation">&gt;</span></span>

    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependencies</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>com.aliyun<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>dysmsapi20170525<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>2.0.8<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>com.stt.yygh<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>rabbitmq-util<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>0.0.1<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependencies</span><span class="token punctuation">&gt;</span></span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>project</span><span class="token punctuation">&gt;</span></span>
</code></pre><div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br></div></div><h4 id="添加配置"><a href="#添加配置" class="header-anchor">#</a> 添加配置</h4> <p>修改<code>application.properties</code>添加rabbitmq依赖</p> <div class="language-properties line-numbers-mode"><pre class="language-properties"><code><span class="token comment">#rabbitmq地址</span>
<span class="token attr-name">spring.rabbitmq.host</span><span class="token punctuation">=</span><span class="token attr-value">localhost</span>
<span class="token attr-name">spring.rabbitmq.port</span><span class="token punctuation">=</span><span class="token attr-value">5672</span>
<span class="token attr-name">spring.rabbitmq.username</span><span class="token punctuation">=</span><span class="token attr-value">guest</span>
<span class="token attr-name">spring.rabbitmq.password</span><span class="token punctuation">=</span><span class="token attr-value">guest</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div><h4 id="在module中添加短信实体"><a href="#在module中添加短信实体" class="header-anchor">#</a> 在module中添加短信实体</h4> <p>在<code>module</code>中新建<code>com.stt.yygh.vo.msm.MsmVo</code> 类，如果已经创建可以忽略</p> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>vo<span class="token punctuation">.</span>msm</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token namespace">io<span class="token punctuation">.</span>swagger<span class="token punctuation">.</span>annotations<span class="token punctuation">.</span></span><span class="token class-name">ApiModel</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">io<span class="token punctuation">.</span>swagger<span class="token punctuation">.</span>annotations<span class="token punctuation">.</span></span><span class="token class-name">ApiModelProperty</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">lombok<span class="token punctuation">.</span></span><span class="token class-name">Data</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">Map</span><span class="token punctuation">;</span>

<span class="token annotation punctuation">@Data</span>
<span class="token annotation punctuation">@ApiModel</span><span class="token punctuation">(</span>description <span class="token operator">=</span> <span class="token string">&quot;短信实体&quot;</span><span class="token punctuation">)</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">MsmVo</span> <span class="token punctuation">{</span>
    
    <span class="token annotation punctuation">@ApiModelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;phone&quot;</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">String</span> phone<span class="token punctuation">;</span>
    
    <span class="token annotation punctuation">@ApiModelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;短信模板code&quot;</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">String</span> templateCode<span class="token punctuation">;</span>
    
    <span class="token annotation punctuation">@ApiModelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;短信模板参数&quot;</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">Map</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span><span class="token class-name">Object</span><span class="token punctuation">&gt;</span></span> param<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br></div></div><h4 id="添加service方法与实现"><a href="#添加service方法与实现" class="header-anchor">#</a> 添加service方法与实现</h4> <p>在<code>MsmService</code>中添加发送消息实体接口</p> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>msm<span class="token punctuation">.</span>service</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>vo<span class="token punctuation">.</span>msm<span class="token punctuation">.</span></span><span class="token class-name">MsmVo</span><span class="token punctuation">;</span>

<span class="token keyword">public</span> <span class="token keyword">interface</span> <span class="token class-name">MsmService</span> <span class="token punctuation">{</span>
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
    <span class="token keyword">boolean</span> <span class="token function">send</span><span class="token punctuation">(</span><span class="token class-name">MsmVo</span> msmVo<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div><p>实现该接口</p> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>msm<span class="token punctuation">.</span>service<span class="token punctuation">.</span>impl</span><span class="token punctuation">;</span>
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token annotation punctuation">@Service</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">MsmServiceImpl</span> <span class="token keyword">implements</span> <span class="token class-name">MsmService</span> <span class="token punctuation">{</span>
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
    <span class="token comment">// 由于使用的是同一个短信测试模板，实际开发中需要申请不同的短信模板</span>
    <span class="token annotation punctuation">@Override</span>
    <span class="token keyword">public</span> <span class="token keyword">boolean</span> <span class="token function">send</span><span class="token punctuation">(</span><span class="token class-name">MsmVo</span> msmVo<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">if</span><span class="token punctuation">(</span><span class="token operator">!</span><span class="token class-name">StringUtils</span><span class="token punctuation">.</span><span class="token function">isEmpty</span><span class="token punctuation">(</span>msmVo<span class="token punctuation">.</span><span class="token function">getPhone</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token class-name">String</span> code <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token class-name">String</span><span class="token punctuation">)</span>msmVo<span class="token punctuation">.</span><span class="token function">getParam</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span><span class="token string">&quot;code&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">return</span> <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">send</span><span class="token punctuation">(</span>msmVo<span class="token punctuation">.</span><span class="token function">getPhone</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span>code<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token keyword">return</span> <span class="token boolean">false</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br></div></div><h4 id="添加mq监听器"><a href="#添加mq监听器" class="header-anchor">#</a> 添加mq监听器</h4> <p>创建 <code>com.stt.yygh.msm.receiver.MsmReceiver</code>类，监听key为 <code>ROUTING_MSM_ITEM</code> 消息</p> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>msm<span class="token punctuation">.</span>receiver</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>msm<span class="token punctuation">.</span>service<span class="token punctuation">.</span></span><span class="token class-name">MsmService</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>rabbitmq<span class="token punctuation">.</span></span><span class="token class-name">MqConst</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>vo<span class="token punctuation">.</span>msm<span class="token punctuation">.</span></span><span class="token class-name">MsmVo</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>rabbitmq<span class="token punctuation">.</span>client<span class="token punctuation">.</span></span><span class="token class-name">Channel</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>amqp<span class="token punctuation">.</span>core<span class="token punctuation">.</span></span><span class="token class-name">Message</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>amqp<span class="token punctuation">.</span>rabbit<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span></span><span class="token class-name">Exchange</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>amqp<span class="token punctuation">.</span>rabbit<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span></span><span class="token class-name">Queue</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>amqp<span class="token punctuation">.</span>rabbit<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span></span><span class="token class-name">QueueBinding</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>amqp<span class="token punctuation">.</span>rabbit<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span></span><span class="token class-name">RabbitListener</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>beans<span class="token punctuation">.</span>factory<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span></span><span class="token class-name">Autowired</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>stereotype<span class="token punctuation">.</span></span><span class="token class-name">Component</span><span class="token punctuation">;</span>

<span class="token annotation punctuation">@Component</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">SmsReceiver</span> <span class="token punctuation">{</span>

    <span class="token annotation punctuation">@Autowired</span>
    <span class="token keyword">private</span> <span class="token class-name">MsmService</span> msmService<span class="token punctuation">;</span>

    <span class="token annotation punctuation">@RabbitListener</span><span class="token punctuation">(</span>bindings <span class="token operator">=</span> <span class="token annotation punctuation">@QueueBinding</span><span class="token punctuation">(</span>
            value <span class="token operator">=</span> <span class="token annotation punctuation">@Queue</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token class-name">MqConst</span><span class="token punctuation">.</span>QUEUE_MSM_ITEM<span class="token punctuation">,</span> durable <span class="token operator">=</span> <span class="token string">&quot;true&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
            exchange <span class="token operator">=</span> <span class="token annotation punctuation">@Exchange</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token class-name">MqConst</span><span class="token punctuation">.</span>EXCHANGE_DIRECT_MSM<span class="token punctuation">)</span><span class="token punctuation">,</span>
            key <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token class-name">MqConst</span><span class="token punctuation">.</span>ROUTING_MSM_ITEM<span class="token punctuation">}</span>
    <span class="token punctuation">)</span><span class="token punctuation">)</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">send</span><span class="token punctuation">(</span><span class="token class-name">MsmVo</span> msmVo<span class="token punctuation">,</span> <span class="token class-name">Message</span> message<span class="token punctuation">,</span> <span class="token class-name">Channel</span> channel<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        msmService<span class="token punctuation">.</span><span class="token function">send</span><span class="token punctuation">(</span>msmVo<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br></div></div><h3 id="封装更新排班数量-service-hosp"><a href="#封装更新排班数量-service-hosp" class="header-anchor">#</a> 封装更新排班数量 service-hosp</h3> <h4 id="修改pom添加依赖-2"><a href="#修改pom添加依赖-2" class="header-anchor">#</a> 修改pom添加依赖</h4> <div class="language-xml line-numbers-mode"><pre class="language-xml"><code><span class="token comment">&lt;!--rabbitmq消息队列--&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>com.stt.yygh<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>rabbitmq-util<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>0.0.1<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><h4 id="添加配置-2"><a href="#添加配置-2" class="header-anchor">#</a> 添加配置</h4> <p>修改<code>application.properties</code> 添加rabbitmq配置</p> <div class="language-properties line-numbers-mode"><pre class="language-properties"><code><span class="token comment">#rabbitmq地址</span>
<span class="token attr-name">spring.rabbitmq.host</span><span class="token punctuation">=</span><span class="token attr-value">localhost</span>
<span class="token attr-name">spring.rabbitmq.port</span><span class="token punctuation">=</span><span class="token attr-value">5672</span>
<span class="token attr-name">spring.rabbitmq.username</span><span class="token punctuation">=</span><span class="token attr-value">guest</span>
<span class="token attr-name">spring.rabbitmq.password</span><span class="token punctuation">=</span><span class="token attr-value">guest</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div><h4 id="在module中添加排班信息实体"><a href="#在module中添加排班信息实体" class="header-anchor">#</a> 在module中添加排班信息实体</h4> <p>创建<code>com.stt.yygh.vo.order.OrderMqVo</code>类</p> <p>该对象放一个短信实体，预约下单成功后，发送一条消息，让mq来保证两个消息都发送成功</p> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>vo<span class="token punctuation">.</span>order</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>vo<span class="token punctuation">.</span>msm<span class="token punctuation">.</span></span><span class="token class-name">MsmVo</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">io<span class="token punctuation">.</span>swagger<span class="token punctuation">.</span>annotations<span class="token punctuation">.</span></span><span class="token class-name">ApiModel</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">io<span class="token punctuation">.</span>swagger<span class="token punctuation">.</span>annotations<span class="token punctuation">.</span></span><span class="token class-name">ApiModelProperty</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">lombok<span class="token punctuation">.</span></span><span class="token class-name">Data</span><span class="token punctuation">;</span>

<span class="token annotation punctuation">@Data</span>
<span class="token annotation punctuation">@ApiModel</span><span class="token punctuation">(</span>description <span class="token operator">=</span> <span class="token string">&quot;OrderMqVo&quot;</span><span class="token punctuation">)</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">OrderMqVo</span> <span class="token punctuation">{</span>
   <span class="token annotation punctuation">@ApiModelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;可预约数&quot;</span><span class="token punctuation">)</span>
   <span class="token keyword">private</span> <span class="token class-name">Integer</span> reservedNumber<span class="token punctuation">;</span>

   <span class="token annotation punctuation">@ApiModelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;剩余预约数&quot;</span><span class="token punctuation">)</span>
   <span class="token keyword">private</span> <span class="token class-name">Integer</span> availableNumber<span class="token punctuation">;</span>

   <span class="token annotation punctuation">@ApiModelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;排班id&quot;</span><span class="token punctuation">)</span>
   <span class="token keyword">private</span> <span class="token class-name">String</span> scheduleId<span class="token punctuation">;</span>

   <span class="token annotation punctuation">@ApiModelProperty</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token string">&quot;短信实体&quot;</span><span class="token punctuation">)</span>
   <span class="token keyword">private</span> <span class="token class-name">MsmVo</span> msmVo<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br></div></div><h4 id="添加service方法与实现-2"><a href="#添加service方法与实现-2" class="header-anchor">#</a> 添加service方法与实现</h4> <p>在 <code>ScheduleService</code>类添加接口</p> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>hosp<span class="token punctuation">.</span>service</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>model<span class="token punctuation">.</span>hosp<span class="token punctuation">.</span></span><span class="token class-name">Schedule</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>vo<span class="token punctuation">.</span>hosp<span class="token punctuation">.</span></span><span class="token class-name">ScheduleOrderVo</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>vo<span class="token punctuation">.</span>hosp<span class="token punctuation">.</span></span><span class="token class-name">ScheduleQueryVo</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>data<span class="token punctuation">.</span>domain<span class="token punctuation">.</span></span><span class="token class-name">Page</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">List</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">Map</span><span class="token punctuation">;</span>

<span class="token keyword">public</span> <span class="token keyword">interface</span> <span class="token class-name">ScheduleService</span> <span class="token punctuation">{</span>
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
    <span class="token comment">// 修改排班</span>
    <span class="token keyword">void</span> <span class="token function">update</span><span class="token punctuation">(</span><span class="token class-name">Schedule</span> schedule<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br></div></div><p>在ScheduleServiceImpl类添加接口实现</p> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>hosp<span class="token punctuation">.</span>service<span class="token punctuation">.</span>impl</span><span class="token punctuation">;</span>
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token annotation punctuation">@Service</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">ScheduleServiceImpl</span> <span class="token keyword">implements</span> <span class="token class-name">ScheduleService</span> <span class="token punctuation">{</span>

    <span class="token annotation punctuation">@Autowired</span>
    <span class="token keyword">private</span> <span class="token class-name">ScheduleRepository</span> repository<span class="token punctuation">;</span>
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
    <span class="token annotation punctuation">@Override</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">update</span><span class="token punctuation">(</span><span class="token class-name">Schedule</span> schedule<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        schedule<span class="token punctuation">.</span><span class="token function">setUpdateTime</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">Date</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//主键一致就是更新</span>
        repository<span class="token punctuation">.</span><span class="token function">save</span><span class="token punctuation">(</span>schedule<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br></div></div><h4 id="添加mq监听器-2"><a href="#添加mq监听器-2" class="header-anchor">#</a> 添加mq监听器</h4> <p>创建<code>com.stt.yygh.hosp.receiver.HospitalReceiver</code> 类，接受更新排班数量mq，更新成功后发送短信mq给msm服务</p> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>hosp<span class="token punctuation">.</span>receiver</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>rabbitmq<span class="token punctuation">.</span>client<span class="token punctuation">.</span></span><span class="token class-name">Channel</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>hosp<span class="token punctuation">.</span>service<span class="token punctuation">.</span></span><span class="token class-name">ScheduleService</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>model<span class="token punctuation">.</span>hosp<span class="token punctuation">.</span></span><span class="token class-name">Schedule</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>rabbitmq<span class="token punctuation">.</span></span><span class="token class-name">MqConst</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>rabbitmq<span class="token punctuation">.</span></span><span class="token class-name">RabbitService</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>vo<span class="token punctuation">.</span>order<span class="token punctuation">.</span></span><span class="token class-name">OrderMqVo</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>vo<span class="token punctuation">.</span>msm<span class="token punctuation">.</span></span><span class="token class-name">MsmVo</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>amqp<span class="token punctuation">.</span>core<span class="token punctuation">.</span></span><span class="token class-name">Message</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>amqp<span class="token punctuation">.</span>rabbit<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span></span><span class="token class-name">Exchange</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>amqp<span class="token punctuation">.</span>rabbit<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span></span><span class="token class-name">Queue</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>amqp<span class="token punctuation">.</span>rabbit<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span></span><span class="token class-name">QueueBinding</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>amqp<span class="token punctuation">.</span>rabbit<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span></span><span class="token class-name">RabbitListener</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>beans<span class="token punctuation">.</span>factory<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span></span><span class="token class-name">Autowired</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>stereotype<span class="token punctuation">.</span></span><span class="token class-name">Component</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token namespace">java<span class="token punctuation">.</span>io<span class="token punctuation">.</span></span><span class="token class-name">IOException</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">Objects</span><span class="token punctuation">;</span>

<span class="token annotation punctuation">@Component</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">HospitalReceiver</span> <span class="token punctuation">{</span>

    <span class="token annotation punctuation">@Autowired</span>
    <span class="token keyword">private</span> <span class="token class-name">ScheduleService</span> scheduleService<span class="token punctuation">;</span>

    <span class="token annotation punctuation">@Autowired</span>
    <span class="token keyword">private</span> <span class="token class-name">RabbitService</span> rabbitService<span class="token punctuation">;</span>

    <span class="token annotation punctuation">@RabbitListener</span><span class="token punctuation">(</span>bindings <span class="token operator">=</span> <span class="token annotation punctuation">@QueueBinding</span><span class="token punctuation">(</span>
            value <span class="token operator">=</span> <span class="token annotation punctuation">@Queue</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token class-name">MqConst</span><span class="token punctuation">.</span>QUEUE_ORDER<span class="token punctuation">,</span> durable <span class="token operator">=</span> <span class="token string">&quot;true&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
            exchange <span class="token operator">=</span> <span class="token annotation punctuation">@Exchange</span><span class="token punctuation">(</span>value <span class="token operator">=</span> <span class="token class-name">MqConst</span><span class="token punctuation">.</span>EXCHANGE_DIRECT_ORDER<span class="token punctuation">)</span><span class="token punctuation">,</span>
            key <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token class-name">MqConst</span><span class="token punctuation">.</span>ROUTING_ORDER<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
    <span class="token keyword">public</span> <span class="token keyword">void</span> <span class="token function">receiver</span><span class="token punctuation">(</span><span class="token class-name">OrderMqVo</span> orderMqVo<span class="token punctuation">,</span> <span class="token class-name">Message</span> message<span class="token punctuation">,</span> <span class="token class-name">Channel</span> channel<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">IOException</span> <span class="token punctuation">{</span>
        <span class="token comment">//下单成功更新预约数</span>
        <span class="token class-name">Schedule</span> schedule <span class="token operator">=</span> scheduleService<span class="token punctuation">.</span><span class="token function">getById</span><span class="token punctuation">(</span>orderMqVo<span class="token punctuation">.</span><span class="token function">getScheduleId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        schedule<span class="token punctuation">.</span><span class="token function">setReservedNumber</span><span class="token punctuation">(</span>orderMqVo<span class="token punctuation">.</span><span class="token function">getReservedNumber</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        schedule<span class="token punctuation">.</span><span class="token function">setAvailableNumber</span><span class="token punctuation">(</span>orderMqVo<span class="token punctuation">.</span><span class="token function">getAvailableNumber</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        scheduleService<span class="token punctuation">.</span><span class="token function">update</span><span class="token punctuation">(</span>schedule<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//订单更新成功后发送短信mq</span>
        <span class="token class-name">MsmVo</span> msmVo <span class="token operator">=</span> orderMqVo<span class="token punctuation">.</span><span class="token function">getMsmVo</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span><span class="token class-name">Objects</span><span class="token punctuation">.</span><span class="token function">isNull</span><span class="token punctuation">(</span>msmVo<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            rabbitService<span class="token punctuation">.</span><span class="token function">sendMessage</span><span class="token punctuation">(</span><span class="token class-name">MqConst</span><span class="token punctuation">.</span>EXCHANGE_DIRECT_MSM<span class="token punctuation">,</span> <span class="token class-name">MqConst</span><span class="token punctuation">.</span>ROUTING_MSM_ITEM<span class="token punctuation">,</span> msmVo<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br><span class="line-number">41</span><br><span class="line-number">42</span><br><span class="line-number">43</span><br><span class="line-number">44</span><br><span class="line-number">45</span><br><span class="line-number">46</span><br></div></div><h3 id="调整下单接口-service-order"><a href="#调整下单接口-service-order" class="header-anchor">#</a> 调整下单接口 service-order</h3> <p>实现了更新订单以及发送短信的mq接收功能，下面更改原先的下单接口，添加发送消息功能</p> <h4 id="修改pom添加依赖-3"><a href="#修改pom添加依赖-3" class="header-anchor">#</a> 修改pom添加依赖</h4> <div class="language-xml line-numbers-mode"><pre class="language-xml"><code><span class="token comment">&lt;!--rabbitmq消息队列--&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dependency</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>groupId</span><span class="token punctuation">&gt;</span></span>com.stt.yygh<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>groupId</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>artifactId</span><span class="token punctuation">&gt;</span></span>rabbitmq-util<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>artifactId</span><span class="token punctuation">&gt;</span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>version</span><span class="token punctuation">&gt;</span></span>0.0.1<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>version</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dependency</span><span class="token punctuation">&gt;</span></span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><h4 id="添加配置-3"><a href="#添加配置-3" class="header-anchor">#</a> 添加配置</h4> <p>修改<code>application.properties</code> 添加rabbitmq配置</p> <div class="language-properties line-numbers-mode"><pre class="language-properties"><code><span class="token comment">#rabbitmq地址</span>
<span class="token attr-name">spring.rabbitmq.host</span><span class="token punctuation">=</span><span class="token attr-value">localhost</span>
<span class="token attr-name">spring.rabbitmq.port</span><span class="token punctuation">=</span><span class="token attr-value">5672</span>
<span class="token attr-name">spring.rabbitmq.username</span><span class="token punctuation">=</span><span class="token attr-value">guest</span>
<span class="token attr-name">spring.rabbitmq.password</span><span class="token punctuation">=</span><span class="token attr-value">guest</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div><h4 id="修改下单接口"><a href="#修改下单接口" class="header-anchor">#</a> 修改下单接口</h4> <div class="language-java line-numbers-mode"><pre class="language-java"><code><span class="token keyword">package</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>order<span class="token punctuation">.</span>service<span class="token punctuation">.</span>impl</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>alibaba<span class="token punctuation">.</span>fastjson<span class="token punctuation">.</span></span><span class="token class-name">JSONObject</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>baomidou<span class="token punctuation">.</span>mybatisplus<span class="token punctuation">.</span>extension<span class="token punctuation">.</span>service<span class="token punctuation">.</span>impl<span class="token punctuation">.</span></span><span class="token class-name">ServiceImpl</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>common<span class="token punctuation">.</span>exception<span class="token punctuation">.</span></span><span class="token class-name">YyghException</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>common<span class="token punctuation">.</span>helper<span class="token punctuation">.</span></span><span class="token class-name">HttpRequestHelper</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>common<span class="token punctuation">.</span>result<span class="token punctuation">.</span></span><span class="token class-name">ResultCodeEnum</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>enums<span class="token punctuation">.</span></span><span class="token class-name">OrderStatusEnum</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>hosp<span class="token punctuation">.</span>client<span class="token punctuation">.</span></span><span class="token class-name">HospitalFeignClient</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>model<span class="token punctuation">.</span>order<span class="token punctuation">.</span></span><span class="token class-name">OrderInfo</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>model<span class="token punctuation">.</span>user<span class="token punctuation">.</span></span><span class="token class-name">Patient</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>order<span class="token punctuation">.</span>mapper<span class="token punctuation">.</span></span><span class="token class-name">OrderInfoMapper</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>order<span class="token punctuation">.</span>service<span class="token punctuation">.</span></span><span class="token class-name">OrderService</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>rabbitmq<span class="token punctuation">.</span></span><span class="token class-name">MqConst</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>rabbitmq<span class="token punctuation">.</span></span><span class="token class-name">RabbitService</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>user<span class="token punctuation">.</span>client<span class="token punctuation">.</span></span><span class="token class-name">PatientFeignClient</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>vo<span class="token punctuation">.</span>o<span class="token punctuation">.</span></span><span class="token class-name">OrderMqVo</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>vo<span class="token punctuation">.</span>hosp<span class="token punctuation">.</span></span><span class="token class-name">ScheduleOrderVo</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>vo<span class="token punctuation">.</span>hosp<span class="token punctuation">.</span></span><span class="token class-name">SignInfoVo</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">com<span class="token punctuation">.</span>stt<span class="token punctuation">.</span>yygh<span class="token punctuation">.</span>vo<span class="token punctuation">.</span>msm<span class="token punctuation">.</span></span><span class="token class-name">MsmVo</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>joda<span class="token punctuation">.</span>time<span class="token punctuation">.</span></span><span class="token class-name">DateTime</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>beans<span class="token punctuation">.</span></span><span class="token class-name">BeanUtils</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>beans<span class="token punctuation">.</span>factory<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span></span><span class="token class-name">Autowired</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>stereotype<span class="token punctuation">.</span></span><span class="token class-name">Service</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">org<span class="token punctuation">.</span>springframework<span class="token punctuation">.</span>transaction<span class="token punctuation">.</span>annotation<span class="token punctuation">.</span></span><span class="token class-name">Transactional</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">HashMap</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">Map</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">Objects</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token namespace">java<span class="token punctuation">.</span>util<span class="token punctuation">.</span></span><span class="token class-name">Random</span><span class="token punctuation">;</span>

<span class="token annotation punctuation">@Service</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">OrderServiceImpl</span> <span class="token keyword">extends</span> <span class="token class-name">ServiceImpl</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">OrderInfoMapper</span><span class="token punctuation">,</span> <span class="token class-name">OrderInfo</span><span class="token punctuation">&gt;</span></span> <span class="token keyword">implements</span> <span class="token class-name">OrderService</span> <span class="token punctuation">{</span>
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
    <span class="token annotation punctuation">@Autowired</span>
    <span class="token keyword">private</span> <span class="token class-name">RabbitService</span> rabbitService<span class="token punctuation">;</span>

    <span class="token comment">//保存订单</span>
    <span class="token annotation punctuation">@Override</span>
    <span class="token annotation punctuation">@Transactional</span><span class="token punctuation">(</span>rollbackFor <span class="token operator">=</span> <span class="token class-name">Exception</span><span class="token punctuation">.</span><span class="token keyword">class</span><span class="token punctuation">)</span>
    <span class="token keyword">public</span> <span class="token class-name">Long</span> <span class="token function">saveOrder</span><span class="token punctuation">(</span><span class="token class-name">String</span> scheduleId<span class="token punctuation">,</span> <span class="token class-name">Long</span> patientId<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token class-name">Patient</span> patient <span class="token operator">=</span> patientFeignClient<span class="token punctuation">.</span><span class="token function">getPatientInfo</span><span class="token punctuation">(</span>patientId<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token class-name">Objects</span><span class="token punctuation">.</span><span class="token function">isNull</span><span class="token punctuation">(</span>patient<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token keyword">throw</span> <span class="token keyword">new</span> <span class="token class-name">YyghException</span><span class="token punctuation">(</span><span class="token class-name">ResultCodeEnum</span><span class="token punctuation">.</span>DATA_ERROR<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token class-name">OrderInfo</span> order <span class="token operator">=</span> <span class="token function">createAndSaveOrder</span><span class="token punctuation">(</span>scheduleId<span class="token punctuation">,</span> patient<span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token class-name">JSONObject</span> resp <span class="token operator">=</span> <span class="token function">accessRemoteHospAndCreateOrder</span><span class="token punctuation">(</span>order<span class="token punctuation">,</span> patient<span class="token punctuation">)</span><span class="token punctuation">;</span>

        order<span class="token punctuation">.</span><span class="token function">setHosRecordId</span><span class="token punctuation">(</span>resp<span class="token punctuation">.</span><span class="token function">getString</span><span class="token punctuation">(</span><span class="token string">&quot;hosRecordId&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>    <span class="token comment">//预约记录唯一标识（医院预约记录主键）</span>
        order<span class="token punctuation">.</span><span class="token function">setNumber</span><span class="token punctuation">(</span>resp<span class="token punctuation">.</span><span class="token function">getInteger</span><span class="token punctuation">(</span><span class="token string">&quot;number&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>             <span class="token comment">//预约序号</span>
        order<span class="token punctuation">.</span><span class="token function">setFetchTime</span><span class="token punctuation">(</span>resp<span class="token punctuation">.</span><span class="token function">getString</span><span class="token punctuation">(</span><span class="token string">&quot;fetchTime&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>        <span class="token comment">//取号时间</span>
        order<span class="token punctuation">.</span><span class="token function">setFetchAddress</span><span class="token punctuation">(</span>resp<span class="token punctuation">.</span><span class="token function">getString</span><span class="token punctuation">(</span><span class="token string">&quot;fetchAddress&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  <span class="token comment">//取号地址</span>
        baseMapper<span class="token punctuation">.</span><span class="token function">updateById</span><span class="token punctuation">(</span>order<span class="token punctuation">)</span><span class="token punctuation">;</span>                               <span class="token comment">//更新订单</span>

        <span class="token comment">//排班可预约数</span>
        <span class="token class-name">Integer</span> reservedNumber <span class="token operator">=</span> resp<span class="token punctuation">.</span><span class="token function">getInteger</span><span class="token punctuation">(</span><span class="token string">&quot;reservedNumber&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">//排班剩余预约数</span>
        <span class="token class-name">Integer</span> availableNumber <span class="token operator">=</span> resp<span class="token punctuation">.</span><span class="token function">getInteger</span><span class="token punctuation">(</span><span class="token string">&quot;availableNumber&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">// 发送更新排班信息并发送短信通知</span>
        <span class="token function">sendUpdateMq</span><span class="token punctuation">(</span>order<span class="token punctuation">,</span> reservedNumber<span class="token punctuation">,</span> availableNumber<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">return</span> order<span class="token punctuation">.</span><span class="token function">getId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>

    <span class="token comment">//发送mq信息更新号源和短信通知</span>
    <span class="token keyword">private</span> <span class="token keyword">void</span> <span class="token function">sendUpdateMq</span><span class="token punctuation">(</span><span class="token class-name">String</span> scheduleId<span class="token punctuation">,</span> <span class="token class-name">OrderInfo</span> order<span class="token punctuation">,</span> <span class="token class-name">Integer</span> reservedNumber<span class="token punctuation">,</span> <span class="token class-name">Integer</span> availableNumber<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token class-name">OrderMqVo</span> orderMqVo <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">OrderMqVo</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        orderMqVo<span class="token punctuation">.</span><span class="token function">setScheduleId</span><span class="token punctuation">(</span>order<span class="token punctuation">.</span><span class="token function">getScheduleId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">split</span><span class="token punctuation">(</span><span class="token string">&quot;@&quot;</span><span class="token punctuation">)</span><span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        orderMqVo<span class="token punctuation">.</span><span class="token function">setReservedNumber</span><span class="token punctuation">(</span>reservedNumber<span class="token punctuation">)</span><span class="token punctuation">;</span>
        orderMqVo<span class="token punctuation">.</span><span class="token function">setAvailableNumber</span><span class="token punctuation">(</span>availableNumber<span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token comment">//短信提示</span>
        <span class="token class-name">MsmVo</span> msmVo <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">MsmVo</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        msmVo<span class="token punctuation">.</span><span class="token function">setPhone</span><span class="token punctuation">(</span>order<span class="token punctuation">.</span><span class="token function">getPatientPhone</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">String</span> reserveDate <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">DateTime</span><span class="token punctuation">(</span>order<span class="token punctuation">.</span><span class="token function">getReserveDate</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">toString</span><span class="token punctuation">(</span><span class="token string">&quot;yyyy-MM-dd&quot;</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token punctuation">(</span>order<span class="token punctuation">.</span><span class="token function">getReserveTime</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">==</span> <span class="token number">0</span> <span class="token operator">?</span> <span class="token string">&quot;上午&quot;</span> <span class="token operator">:</span> <span class="token string">&quot;下午&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">Map</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span> <span class="token class-name">Object</span><span class="token punctuation">&gt;</span></span> param <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">HashMap</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span> <span class="token class-name">Object</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span><span class="token punctuation">{</span>
            <span class="token function">put</span><span class="token punctuation">(</span><span class="token string">&quot;title&quot;</span><span class="token punctuation">,</span> order<span class="token punctuation">.</span><span class="token function">getHosname</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">&quot;|&quot;</span> <span class="token operator">+</span> order<span class="token punctuation">.</span><span class="token function">getDepname</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">+</span> <span class="token string">&quot;|&quot;</span> <span class="token operator">+</span> order<span class="token punctuation">.</span><span class="token function">getTitle</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token function">put</span><span class="token punctuation">(</span><span class="token string">&quot;amount&quot;</span><span class="token punctuation">,</span> order<span class="token punctuation">.</span><span class="token function">getAmount</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token function">put</span><span class="token punctuation">(</span><span class="token string">&quot;reserveDate&quot;</span><span class="token punctuation">,</span> reserveDate<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token function">put</span><span class="token punctuation">(</span><span class="token string">&quot;name&quot;</span><span class="token punctuation">,</span> order<span class="token punctuation">.</span><span class="token function">getPatientName</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token function">put</span><span class="token punctuation">(</span><span class="token string">&quot;quitTime&quot;</span><span class="token punctuation">,</span> <span class="token keyword">new</span> <span class="token class-name">DateTime</span><span class="token punctuation">(</span>order<span class="token punctuation">.</span><span class="token function">getQuitTime</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">toString</span><span class="token punctuation">(</span><span class="token string">&quot;yyyy-MM-dd HH:mm&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token comment">// 注意：由于短信测试模板的原因，只有一个code字段可以被读取，其他参数如果短信模板支持可以添加</span>
            <span class="token comment">// 11111 在测试时表示创建成功</span>
            <span class="token function">put</span><span class="token punctuation">(</span><span class="token string">&quot;code&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;11111&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span><span class="token punctuation">}</span><span class="token punctuation">;</span>
        msmVo<span class="token punctuation">.</span><span class="token function">setParam</span><span class="token punctuation">(</span>param<span class="token punctuation">)</span><span class="token punctuation">;</span>
        orderMqVo<span class="token punctuation">.</span><span class="token function">setMsmVo</span><span class="token punctuation">(</span>msmVo<span class="token punctuation">)</span><span class="token punctuation">;</span>
        rabbitService<span class="token punctuation">.</span><span class="token function">sendMessage</span><span class="token punctuation">(</span><span class="token class-name">MqConst</span><span class="token punctuation">.</span>EXCHANGE_DIRECT_ORDER<span class="token punctuation">,</span> <span class="token class-name">MqConst</span><span class="token punctuation">.</span>ROUTING_ORDER<span class="token punctuation">,</span> orderMqVo<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br><span class="line-number">41</span><br><span class="line-number">42</span><br><span class="line-number">43</span><br><span class="line-number">44</span><br><span class="line-number">45</span><br><span class="line-number">46</span><br><span class="line-number">47</span><br><span class="line-number">48</span><br><span class="line-number">49</span><br><span class="line-number">50</span><br><span class="line-number">51</span><br><span class="line-number">52</span><br><span class="line-number">53</span><br><span class="line-number">54</span><br><span class="line-number">55</span><br><span class="line-number">56</span><br><span class="line-number">57</span><br><span class="line-number">58</span><br><span class="line-number">59</span><br><span class="line-number">60</span><br><span class="line-number">61</span><br><span class="line-number">62</span><br><span class="line-number">63</span><br><span class="line-number">64</span><br><span class="line-number">65</span><br><span class="line-number">66</span><br><span class="line-number">67</span><br><span class="line-number">68</span><br><span class="line-number">69</span><br><span class="line-number">70</span><br><span class="line-number">71</span><br><span class="line-number">72</span><br><span class="line-number">73</span><br><span class="line-number">74</span><br><span class="line-number">75</span><br><span class="line-number">76</span><br><span class="line-number">77</span><br><span class="line-number">78</span><br><span class="line-number">79</span><br><span class="line-number">80</span><br><span class="line-number">81</span><br><span class="line-number">82</span><br><span class="line-number">83</span><br><span class="line-number">84</span><br><span class="line-number">85</span><br><span class="line-number">86</span><br><span class="line-number">87</span><br><span class="line-number">88</span><br><span class="line-number">89</span><br><span class="line-number">90</span><br><span class="line-number">91</span><br></div></div><h2 id="前端实现-yygh-site"><a href="#前端实现-yygh-site" class="header-anchor">#</a> 前端实现 yygh-site</h2> <h3 id="封装api请求"><a href="#封装api请求" class="header-anchor">#</a> 封装api请求</h3> <p>添加/api/order/orderInfo.js文件，定义下单接口</p> <div class="language-js line-numbers-mode"><pre class="language-js"><code><span class="token keyword">import</span> request <span class="token keyword">from</span> <span class="token string">'@/utils/request'</span>

<span class="token keyword">const</span> api_name <span class="token operator">=</span> <span class="token template-string"><span class="token template-punctuation string">`</span><span class="token string">/api/order/orderInfo</span><span class="token template-punctuation string">`</span></span>

<span class="token keyword">export</span> <span class="token keyword">function</span> <span class="token function">submitOrder</span><span class="token punctuation">(</span><span class="token parameter">scheduleId<span class="token punctuation">,</span> patientId</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> <span class="token function">request</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
    <span class="token literal-property property">url</span><span class="token operator">:</span> <span class="token template-string"><span class="token template-punctuation string">`</span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>api_name<span class="token interpolation-punctuation punctuation">}</span></span><span class="token string">/auth/submitOrder/</span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>scheduleId<span class="token interpolation-punctuation punctuation">}</span></span><span class="token string">/</span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>patientId<span class="token interpolation-punctuation punctuation">}</span></span><span class="token template-punctuation string">`</span></span><span class="token punctuation">,</span>
    <span class="token literal-property property">method</span><span class="token operator">:</span> <span class="token string">'post'</span>
  <span class="token punctuation">}</span><span class="token punctuation">)</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div><h3 id="修改页面"><a href="#修改页面" class="header-anchor">#</a> 修改页面</h3> <p>在/pages/hospital/booking.vue组件完善下单方法</p> <div class="language-vue line-numbers-mode"><pre class="language-vue"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>template</span><span class="token punctuation">&gt;</span></span>
...
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>template</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>script</span><span class="token punctuation">&gt;</span></span><span class="token script"><span class="token language-javascript">
<span class="token operator">...</span>
<span class="token keyword">import</span> <span class="token punctuation">{</span> submitOrder <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'@/api/order/orderInfo'</span>

<span class="token keyword">export</span> <span class="token keyword">default</span> <span class="token punctuation">{</span>
<span class="token operator">...</span>
  <span class="token literal-property property">methods</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token operator">...</span>
    <span class="token function">submitOrder</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">.</span>patient<span class="token punctuation">.</span>id <span class="token operator">==</span> <span class="token keyword">null</span><span class="token punctuation">)</span> <span class="token keyword">return</span> <span class="token keyword">this</span><span class="token punctuation">.</span>$message<span class="token punctuation">.</span><span class="token function">error</span><span class="token punctuation">(</span><span class="token string">'请选择就诊人'</span><span class="token punctuation">)</span>
      <span class="token comment">// 防止重复提交</span>
      <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">.</span>submitBnt <span class="token operator">===</span> <span class="token string">'正在提交...'</span><span class="token punctuation">)</span> <span class="token keyword">return</span> <span class="token keyword">this</span><span class="token punctuation">.</span>$message<span class="token punctuation">.</span><span class="token function">error</span><span class="token punctuation">(</span><span class="token string">'重复提交'</span><span class="token punctuation">)</span>
      <span class="token keyword">this</span><span class="token punctuation">.</span>submitBnt <span class="token operator">=</span> <span class="token string">'正在提交...'</span>
      <span class="token function">submitOrder</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">.</span>scheduleId<span class="token punctuation">,</span> <span class="token keyword">this</span><span class="token punctuation">.</span>patient<span class="token punctuation">.</span>id<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">then</span><span class="token punctuation">(</span><span class="token parameter">res</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
        <span class="token keyword">let</span> orderId <span class="token operator">=</span> res<span class="token punctuation">.</span>data
        window<span class="token punctuation">.</span>location<span class="token punctuation">.</span>href <span class="token operator">=</span> <span class="token string">'/order/show?orderId='</span> <span class="token operator">+</span> orderId
      <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">catch</span><span class="token punctuation">(</span><span class="token parameter">e</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
        <span class="token keyword">this</span><span class="token punctuation">.</span>submitBnt <span class="token operator">=</span> <span class="token string">'确认挂号'</span>
      <span class="token punctuation">}</span><span class="token punctuation">)</span>
    <span class="token punctuation">}</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>script</span><span class="token punctuation">&gt;</span></span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br></div></div><h2 id="测试"><a href="#测试" class="header-anchor">#</a> 测试</h2> <p>重新启动service-order，service-hosp，service-user，service-cmn，service-gateway等服务，以及nacos和rabbitmq</p> <p>注意：需要启动医院模拟系统，本次启用后的端口号是9998，用于接收创建的订单请求</p> <p>选择医院-&gt;选择科室-&gt;选择一个预约日期-&gt;选择一个医生-&gt;进入-&gt;点击确认挂号按键</p> <p><img src="/assets/img/testBooking.f89fe381.png" alt=""></p> <p>确认完成后，会收到短信，以及在数据库中会有订单记录，以及预约号会减少</p></div></div>  <div class="page-edit"><!----> <!----> <div class="last-updated"><span class="prefix">Last Updated:</span> <span class="time">2022/01/16, 11:29:51</span></div></div> <div class="page-nav-wapper"><div class="page-nav-centre-wrap"><a href="/pages/42181a/" class="page-nav-centre page-nav-centre-prev"><div class="tooltip">30.前台系统-预约确认</div></a> <a href="/pages/9b5903/" class="page-nav-centre page-nav-centre-next"><div class="tooltip">32.前台系统-订单管理</div></a></div> <div class="page-nav"><p class="inner"><span class="prev">
        ←
        <a href="/pages/42181a/" class="prev">30.前台系统-预约确认</a></span> <span class="next"><a href="/pages/9b5903/">32.前台系统-订单管理</a>→
      </span></p></div></div></div> <!----></main></div> <div class="footer"><div class="icons"><a href="mailto:work_stt@163.com" title="email" target="_blank" class="iconfont icon-youjian"></a><a href="https://github.com/shetengteng" title="GitHub" target="_blank" class="iconfont icon-github"></a></div> 
  Theme by
  <a href="https://github.com/xugaoyi/vuepress-theme-vdoing" target="_blank" title="本站主题">Vdoing</a> 
    | Copyright © 2021-2022
    <span>Shetengteng | MIT License</span></div> <div class="buttons"><div title="返回顶部" class="button blur go-to-top iconfont icon-fanhuidingbu" style="display:none;"></div> <div title="去评论" class="button blur go-to-comment iconfont icon-pinglun" style="display:none;"></div> <div title="主题模式" class="button blur theme-mode-but iconfont icon-zhuti"><ul class="select-box" style="display:none;"><li class="iconfont icon-zidong">
          跟随系统
        </li><li class="iconfont icon-rijianmoshi">
          浅色模式
        </li><li class="iconfont icon-yejianmoshi">
          深色模式
        </li><li class="iconfont icon-yuedu">
          阅读模式
        </li></ul></div></div> <!----> <!----> <!----></div><div class="global-ui"><div></div></div></div>
    <script src="/assets/js/app.ab6a7ec7.js" defer></script><script src="/assets/js/2.bc9beebf.js" defer></script><script src="/assets/js/104.75b80350.js" defer></script>
  </body>
</html>
